Next Ruby Quiz: same return value or different? Also what value do they return?

def foo(_ = 1, _: 2)
_
end

def bar(_ = 1, _: 1 + 1)
_
end

p foo
p bar

3
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
0
10mo
yopp

@tenderlove let me guess: bar will return different value because keyword arg is expression instead of plain literal?

1
10mo
Phi Φ

@tenderlove

2
2

Rubyist (mruby)

Screenshot of code quiz execution via Rubyist app on iOS
0
10mo
Replies