Skip to content

Instantly share code, notes, and snippets.

@rafbm
Created July 16, 2012 21:49
Show Gist options
  • Save rafbm/3125310 to your computer and use it in GitHub Desktop.
Save rafbm/3125310 to your computer and use it in GitHub Desktop.
Methods ending in “=” that accept a single argument will treat multiple arguments as an array.
# Methods ending in “=” that accept a single argument will treat multiple arguments as an array.
class Foo
def types=(array)
p array
end
end
foo = Foo.new
foo.types = [:bar, :baz, :quux] # => [:bar, :baz, :quux]
foo.types = :bar, :baz, :quux # => [:bar, :baz, :quux]
# Previous two lines are equivalent, w00t!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment