Skip to content

Instantly share code, notes, and snippets.

@gongo
Last active January 28, 2022 00:39
Show Gist options
  • Save gongo/c404167ae49165acd4df63c27ae1a54c to your computer and use it in GitHub Desktop.
Save gongo/c404167ae49165acd4df63c27ae1a54c to your computer and use it in GitHub Desktop.
それぞれのメソッドで「戻り値になるのはこれとこれ」っていうリストを作りたい
# こういうことをしてくれる 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