Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created October 16, 2019 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igaiga/9121afba6c9a13292e38fcb63976def0 to your computer and use it in GitHub Desktop.
Save igaiga/9121afba6c9a13292e38fcb63976def0 to your computer and use it in GitHub Desktop.
# Rubyでメソッドと、そうではないもの(式とか)の見分け方
# methodメソッドで取得できたらメソッド
method(:p) #=> #<Method: main.p>
# ↑とれたのでメソッド
method(:for)
#=> NameError: undefined method `for' for class `#<Class:#<Object:0x00007fd82d0d22f0>>'
# ↑とれないのでメソッドではない
5.method(:times) #=> #<Method: Integer#times>
# ↑とれたのでメソッド
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment