Skip to content

Instantly share code, notes, and snippets.

@patricksrobertson
Created October 29, 2012 13:04
Show Gist options
  • Save patricksrobertson/3973419 to your computer and use it in GitHub Desktop.
Save patricksrobertson/3973419 to your computer and use it in GitHub Desktop.
oh god dont show them how to perpetuate option hash passing in coffescript.
# so very bad
class Blerg
constructor: (@options = {}) ->
byLine: ->
"by #{@options.author.fullName()}"
category: ->
@options.category
author = new Author firstName: "Jim", lastName: "Johnson"
cat = new Category 'ridin dirty'
blagh = new Blerg author: author, category: cat
# betterer
class Blerg
constructor: (@author, @category) ->
byLine: ->
"by #{@author.fullName()}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment