Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Created February 24, 2015 17:44
Show Gist options
  • Save denisdefreyne/e5f2ead27d2cc463c7dc to your computer and use it in GitHub Desktop.
Save denisdefreyne/e5f2ead27d2cc463c7dc to your computer and use it in GitHub Desktop.
Arrays?!
class Stuff
def initialize(params = {})
@foo_name = params.fetch(:foo_name)
@foo_identifier = params.fetch(:foo_identifier)
@bar_name = params.fetch(:bar_name),
@bar_identifier = params.fetch(:bar_identifier)
end
def to_a
[
@foo_name,
@foo_identifier,
@bar_name,
@bar_identifier,
]
end
end
p Stuff.new(foo_name: 'The Foo', foo_identifier: '/foo', bar_name: 'The Bar', bar_identifier: '/bar')
# #<Stuff:0x007fe343848068 @foo_name="The Foo", @foo_permalink="/foo", @bar_permalink="/bar", @bar_name=["The Bar", "/bar"]>
@denisdefreyne
Copy link
Author

Why is bar_name an array?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment