Last active
August 29, 2015 14:06
-
-
Save yuchan/d08adba0b64a1862c773 to your computer and use it in GitHub Desktop.
Learning CoffeeScript
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
animals = [ | |
'dog', | |
'cat', | |
'elephant'] | |
console.log animals |
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 CoffeeCup | |
constructor: -> | |
@properties = | |
strength: 'medium' | |
cream: false | |
sugar: false | |
strength: (newStrength) -> | |
@properties.strength = newStrength | |
this |
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 Songs | |
@_titles: 0 | |
@get_count: -> | |
@_titles | |
constructor: (@artist, @title) -> | |
Songs._titles++ | |
console.log Songs.get_count() | |
song = new Songs("Billy Joel", "Piano Man") | |
console.log Songs.get_count() | |
song.get_count() |
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 Songs | |
_titles: 0 | |
get_count: -> | |
@_titles | |
constructor: (@artist, @title) -> | |
@_titles++ | |
song = new Songs("Taylor Swift", "22") | |
console.log song.get_count() | |
Songs.get_count() | |
class Klass | |
constructor:(@artist, @title) -> | |
getArtist: -> | |
@artist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment