→ swpoker:都是物件~Function只不過是個可執行的物件罷了 03/21 09:08
Groovy可以很簡單的使用字串作為方法名稱, 例如:
def "this is method1"(){
println 'From method1'
}
然後這樣叫用:
"this is method1"()
obj."this is method1"()
甚至這樣也行
def '''this
is
method2'''(){
println 'From method2'
}
雖然是個有的時候算有用的feature
但我想了解這件事情究竟是怎麼完成的呢?
能否了解Groovy的版友能稍微解說一下, 感激不盡:)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.134.11