CoffeeScript Anonymous Functions

by ctoestreich

HTML

<script src="http://codemirror.net/lib/codemirror.js"></script>
<link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css">
<script src="http://codemirror.net/mode/javascript/javascript.js"></script>
<script type="text/javascript">$.get('http://fiddle.jshell.net/bh88/SKMpV/show/',function(){$('#code').val(CoffeeScript.compile($('script[type*=coffeescript]').html()));var editor=CodeMirror.fromTextArea(document.getElementById('code'),{lineNumbers:1,matchBrackets:1,mode:'javascript'});});</script><textarea id="code"></textarea>

CSS

/* here's that gist btw https://gist.github.com/1293230 */

#code {
    display: none;
}

.CodeMirror-scroll {
    height: 100% !important;            
}

CoffeeScript

###
See: http://jsfiddle.net/ctoestreich/aRYSz/
The returns at the end of the anonymous function and at the end of the method tell coffee
to not use the return statement in the loop or in the method, otherwise the last statement
in each function or anonymous function will be a return statement
###
loopingMethod = ->
  # do some loop using jQuery each method
  $([1,2,3,4,5]).each (index, value) ->
    console.log index, value
    return
  return

do loopingMethod