Skip to content

Instantly share code, notes, and snippets.

@joshskeen
Created February 26, 2013 20:49
Show Gist options
  • Save joshskeen/5042046 to your computer and use it in GitHub Desktop.
Save joshskeen/5042046 to your computer and use it in GitHub Desktop.
Keyword arguments test!
class TestFoo
def initialize(foo: nil, baz: nil, is_awesome: nil, this_ones_required: nil)
@foo = foo
@baz = baz
@is_awesome = is_awesome
@this_ones_required = this_ones_required or raise ArgumentError.new("this ones required!")
end
def to_s
"foo: #{@foo}, baz: #{@baz}, is_awesome: #{@is_awesome.to_s}, this_ones_required: #{@this_ones_required}"
end
end
test = TestFoo.new(this_ones_required: true, baz: "QAZ!!", is_awesome: true, foo: "howdy yall")
puts test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment