1
if (ax_response = OpenID::AX::FetchResponse.from_success_response openid_response)
上述行如果我刪除()palenthesis它會引發語法錯誤..意外的tIdentifier。爲什麼?爲什麼remove()for ruby條件引發錯誤?
if (ax_response = OpenID::AX::FetchResponse.from_success_response openid_response)
上述行如果我刪除()palenthesis它會引發語法錯誤..意外的tIdentifier。爲什麼?爲什麼remove()for ruby條件引發錯誤?
Ruby非常擅長挑選任意語法,但沒有括號可以指導它,有時它無法弄清楚你的意圖。在這種情況下,你有兩個選擇。圍繞if
聲明
支架:
周圍參數if (var = method arg)
end
支架:
if var = method(arg)
end
沒有某種執教它的不是要能夠鎖定在你的語句的準確含義。如果您來自像Perl,C++或JavaScript這樣的背景,其中的括號不是可選的,那麼這絕不是問題。 Ruby非常寬容。
是的答案。謝謝@MrYoshiji – 2013-02-19 19:56:06
你能發佈整個異常嗎? – Automatico 2013-02-19 19:42:15
哪個標識符是問題?如果僅在'.from_success_response'調用周圍放置括號,或者僅在'openid_response'周圍放置括號,它會起作用嗎? – 2013-02-19 19:43:18
你想把結果賦給'ax_response'還是測試相等? – iamnotmaynard 2013-02-19 19:47:48