Last active
August 29, 2015 14:04
-
-
Save jgaskins/7f8d020302fc1ca0f88e to your computer and use it in GitHub Desktop.
Default values
This file contains 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 Foo | |
def initialize: (attributes={}) -> | |
# Set default day to Monday | |
# This broke for Sunday (attributes.day == 0) | |
@day = attributes.day || 1 | |
# How I ended up doing it | |
@day = if attributes.hasOwnProperty('day') then attributes.day else 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment