Skip to content

Instantly share code, notes, and snippets.

@netzpirat
Created May 4, 2011 19:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netzpirat/955851 to your computer and use it in GitHub Desktop.
Save netzpirat/955851 to your computer and use it in GitHub Desktop.
Return nothing from a CoffeeScript function
# Everything is an Expression
->
greeting = 'Hi CoffeeScripter'
# Expect it's undefined
->
greeting = 'Hi CoffeeScripter'
return undefined
(function() {
(function() {
var greeting;
return greeting = 'Hi CoffeeScripter';
});
(function() {
var greeting;
greeting = 'Hi CoffeeScripter';
});
}).call(this);
@alg
Copy link

alg commented May 29, 2011

You can do the same by just saying "return" (without "undefined").

@creamidea
Copy link

Is there a global setting/configure to avoid writing "return"? The programmer can control the "return". I mean that return when we write it??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment