def map.hello() p "Hello World" end p map.singleton_methods() 返回用戶對該對象變數單獨定義的方法。 輸出結果:
參考資料: A method
given only to a single object is called a singleton method. http://www.rubyist.net/~slagell/ruby/singletonmethods.html 這篇文章詳細的介紹了什麼是Singleton Method。