kemiller / rubymotion-style-guide

A community-driven RubyMotion coding style guide
18 stars 2 forks source link

New methods: Named parameters vs. argument hash #1

Closed jamonholmgren closed 6 years ago

jamonholmgren commented 11 years ago

Example:

# Named parameters
def my_method(my_title, with_size: my_size)
  # ...
end

# Argument hash
def my_method(args={})
  # ...
end

I prefer the argument hash.

kemiller commented 11 years ago

I like argument hash because it's familiar and more flexible. You can leave args out or reorder them.

Only place I'd want to use named args is if I'm writing something to look like a initWith... method, but that's another ticket.

jamonholmgren commented 6 years ago

I agree.