Skip to content

Instantly share code, notes, and snippets.

@yuchan
Last active August 29, 2015 14:06
Show Gist options
  • Save yuchan/d08adba0b64a1862c773 to your computer and use it in GitHub Desktop.
Save yuchan/d08adba0b64a1862c773 to your computer and use it in GitHub Desktop.
Learning CoffeeScript
animals = [
'dog',
'cat',
'elephant']
console.log animals
class CoffeeCup
constructor: ->
@properties =
strength: 'medium'
cream: false
sugar: false
strength: (newStrength) ->
@properties.strength = newStrength
this
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()
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