-
-
Save clamstew/6705022 to your computer and use it in GitHub Desktop.
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
def initialize (args={:event_time, :deadline, :event_name, :event_location, :minimum_attendees, :maximum_attendees, :creator_name, :phone, :email, :invitees}) | |
@required = args.fetch(:event_time, :deadline, :minimum_attendees) # .fetch will throw an error if key doesn't exist in Hash | |
@optional = args[:creator, :event_name, :event_location, :attendees, :maximum_attendees] # simple access returns nil if key isn't set--no exception raised | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of putting optional parameters in the initialize method of a class.