Created
June 17, 2013 18:55
-
-
Save benhamill/5799313 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 new(first_name: 'Ben', | |
last_name: 'Hamill', | |
birthday: '1982/02/13', | |
title: 'Software Engineer') | |
@name = "#{first_name} #{last_name}" | |
@birthday = Date.parse(birthday) | |
@title = title | |
end | |
def new( | |
first_name: 'Ben', | |
last_name: 'Hamill', | |
birthday: '1982/02/13', | |
title: 'Software Engineer' | |
) | |
@name = "#{first_name} #{last_name}" | |
@birthday = Date.parse(birthday) | |
@title = title | |
end | |
def new( | |
first_name: 'Ben', | |
last_name: 'Hamill', | |
birthday: '1982/02/13', | |
title: 'Software Engineer' | |
) | |
@name = "#{first_name} #{last_name}" | |
@birthday = Date.parse(birthday) | |
@title = title | |
end |
I started with #2, but the same-indent-levelness of the method body is bad. Here is another:
def new(
first_name: 'Ben',
last_name: 'Hamill',
birthday: '1982/02/13',
title: 'Software Engineer')
@name = "#{first_name} #{last_name}"
@birthday = Date.parse(birthday)
@title = title
end
The same way as my non-keyword arguments, of course:
def new(first_name: 'Ben', last_name: 'Hamill', birthday: '1982/02/13',
title: 'Software Engineer')
@name = "#{first_name} #{last_name}"
@birthday = Date.parse(birthday)
@title = title
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I hate the first one least.