Skip to content

Instantly share code, notes, and snippets.

@Radagaisus
Created August 3, 2012 18:36
Show Gist options
  • Select an option

  • Save Radagaisus/3250296 to your computer and use it in GitHub Desktop.

Select an option

Save Radagaisus/3250296 to your computer and use it in GitHub Desktop.
I wonder if this is better or worse
getQuantity: (item_id) -> (i.quantity for i in items when i.id is item_id)[0]
# Or:
getQuantity: (item_id) ->
for i in @items
return i.quantity if i.item_id is item_id
undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment