Skip to content

Instantly share code, notes, and snippets.

@benhamill
Created June 17, 2013 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhamill/5799313 to your computer and use it in GitHub Desktop.
Save benhamill/5799313 to your computer and use it in GitHub Desktop.
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
@benhamill
Copy link
Author

I hate the first one least.

@ngauthier
Copy link

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

@jgoldschrafe
Copy link

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