Created
          November 24, 2012 03:27 
        
      - 
      
 - 
        
Save jay3sh/4138237 to your computer and use it in GitHub Desktop.  
    Switch-To-Coffeescript-Code-Snippets
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | methodfoo : (arg0) -> | |
| func = => x = @someproperty | |
| func() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | SomeClass.prototype.methodfoo = function (arg0) { | |
| var thisref = this; | |
| var func = function () { | |
| var x = thisref.someproperty; | |
| } | |
| func(); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | for item in arr | |
| process(item) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | for (_i = 0, _len = arr.length; _i < _len; _i++) { | |
| item = arr[_i]; | |
| process(item); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | foo = ({newArg, arg0, arg1}) -> | |
| newArg ?= 42 # default value | |
| foo(arg0:'A', arg1:1) | |
| foo(newArg:24, arg0:'B', arg1:2) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Person | |
| constructor : ({name}) -> | |
| @name = name | |
| getName : () -> | |
| return @name | |
| class Manager extends Person | |
| getReportingEngineers : () -> | |
| class Engineer extends Person | |
| getManager : () -> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | proplist = _(itemlist).map (x)->x.property | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | proplist = _(itemlist).map(function(x) { | |
| return x.property; | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | "My name is #{@name}. I am #{@age} years old" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | "My name is " + this.name + ". I am " + this.age + " years old"; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment