# Ruby 小知識02:用 send() 指令在方法召喚其他方法 ###### tags: `Ruby` ```ruby= def attack(move) send(move) end def punch puts("atk100") end def bite puts("atk250") end # 這時如果要攻擊除了直接寫punch bite之外也可以 attack(:punch) ``` 因為send() 裡面帶進去的Key,會觸發方法
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up