Is there a more concise Coffeescript idiom for this?

mattecapu

I'm trying to translate this Javascript code:

if(error) {
    foo();
    return null;
}
bar()

into Coffeescript code, where here bar() is another long piece of code which I don't want to indent more

Is there a better way than this?

if error
    foo()
    return null
bar()
Leonid Beschastny

Your code looks fine for me.

Though, if you really want it to be a one-liner, you could take advantage of parentheses:

return (foo(); null) if error

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

More concise way of making quadratically spaced sequence?

From Dev

Is there a more concise way to initialize empty multidimensional arrays?

From Dev

More concise HashMap initialization

From Dev

Writing more concise code in go

From Dev

how to write this function in more concise manner in python

From Dev

Is there a simpler/ more concise way to initialize this array in Lua?

From Dev

CoffeeScript idiom for Array.reduce with default value

From Dev

Scala make multiple option checks more concise

From Dev

If/yield cascade - how to make more concise?

From Dev

More concise solution using regex in java

From Dev

Is there a more concise way to read csv files in Python?

From Dev

More concise way to rotate the digits of a number in J

From Dev

How can I make this method more concise?

From Dev

What is a concise and clear idiom for mapping values into a data.table

From Dev

Can this Scala code snippet be made more concise?

From Dev

More concise LINQ with 'or' clause

From Dev

How can I refactor this code to be more concise?

From Dev

A more concise version of this Regular Expression?

From Dev

Making a Swift Array Statement More Concise

From Dev

A more concise way to create an array, fill it, then return it?

From Dev

Coffeescript idiom equivalent to Python's for/else?

From Dev

Can a call to $http be made more concise?

From Dev

Is there a more concise way of coding this in ruby?

From Dev

Looking for a more concise way to recategorise a variable

From Dev

If/yield cascade - how to make more concise?

From Dev

Concatenating text in PL/SQL in a more concise way

From Dev

Making a Swift Array Statement More Concise

From Dev

Is there a more concise way of assigning properties to components in react?

From Dev

Is there a way to make constructor assignments more concise (and simple)?

Related Related

  1. 1

    More concise way of making quadratically spaced sequence?

  2. 2

    Is there a more concise way to initialize empty multidimensional arrays?

  3. 3

    More concise HashMap initialization

  4. 4

    Writing more concise code in go

  5. 5

    how to write this function in more concise manner in python

  6. 6

    Is there a simpler/ more concise way to initialize this array in Lua?

  7. 7

    CoffeeScript idiom for Array.reduce with default value

  8. 8

    Scala make multiple option checks more concise

  9. 9

    If/yield cascade - how to make more concise?

  10. 10

    More concise solution using regex in java

  11. 11

    Is there a more concise way to read csv files in Python?

  12. 12

    More concise way to rotate the digits of a number in J

  13. 13

    How can I make this method more concise?

  14. 14

    What is a concise and clear idiom for mapping values into a data.table

  15. 15

    Can this Scala code snippet be made more concise?

  16. 16

    More concise LINQ with 'or' clause

  17. 17

    How can I refactor this code to be more concise?

  18. 18

    A more concise version of this Regular Expression?

  19. 19

    Making a Swift Array Statement More Concise

  20. 20

    A more concise way to create an array, fill it, then return it?

  21. 21

    Coffeescript idiom equivalent to Python's for/else?

  22. 22

    Can a call to $http be made more concise?

  23. 23

    Is there a more concise way of coding this in ruby?

  24. 24

    Looking for a more concise way to recategorise a variable

  25. 25

    If/yield cascade - how to make more concise?

  26. 26

    Concatenating text in PL/SQL in a more concise way

  27. 27

    Making a Swift Array Statement More Concise

  28. 28

    Is there a more concise way of assigning properties to components in react?

  29. 29

    Is there a way to make constructor assignments more concise (and simple)?

HotTag

Archive