譬如:
def calculate(*numbers, method = {:add=>true})
就一直報(bào)錯(cuò):
syntax error, unexpected '=', expecting ')' (SyntaxError)
檢索The Ruby Programming Wikibook 的相關(guān)語法也沒有提示,請(qǐng)問這是什么原因呢?
小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。
Suppose you are the interpreter, what would you do with calculate({add: true})
中的參數(shù) {add: true}
分配給 *numbers
呢,還是 method
?
You can’t judge at all, right? So it's not allowed.
Can’t this kind of *numbers
variable parameters only be at the end?
def calc(method = {add: true}, *numbers); end
is allowed, but the reverse is not allowed.