Last active
January 28, 2022 00:39
-
-
Save gongo/c404167ae49165acd4df63c27ae1a54c 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
# こういうことをしてくれる nanika_no_method が欲しい | |
# Ripper とかそこらへん使えばいけるのだろうか | |
nanika_no_method(<<EOS) | |
def gongo1 | |
'a' | |
end | |
EOS | |
# => ['a'] | |
nanika_no_method(<<EOS) | |
def gongo2(num) | |
num.odd? ? 'b' : 'c' | |
end | |
EOS | |
# => ['b', 'c'] | |
nanika_no_method(<<EOS) | |
def gongo3(num1, num2) | |
return 'd' if num1.odd? | |
num2.odd? ? 'e' : 'f' | |
end | |
EOS | |
# => ['d', 'e', 'f'] | |
nanika_no_method(<<EOS) | |
def gongo4(num1, num2) | |
num1 + num2 | |
end | |
EOS | |
# => こういうのは対応しなくてOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment