Last active
August 29, 2015 14:14
-
-
Save enebo/bcba5f4159314ddfdbcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def to_hash | |
1 | |
end | |
end | |
foo = Foo.new | |
r1kr1 = proc { |a, b:| [a, b] } | |
p r1kr1.call(1, b: 2) | |
begin | |
r1kr1.call(1) | |
rescue # #<ArgumentError: missing keyword: b> | |
p $! | |
end | |
begin | |
r1kr1.call(1, foo) | |
rescue # #<TypeError: can't convert Foo to Hash (Foo#to_hash gives Fixnum)> | |
p $! | |
end | |
p r1kr1.call(1, {b: 2}, 3, {b: 6}) | |
r1ko1 = proc { |a, b: 2| [a, b] } | |
p r1ko1.call(1, b: 3) | |
p r1ko1.call(1) | |
# If required or optional or rest kwargs we potentially can have one | |
# more parameter. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment