LoginSignup
5
4

More than 5 years have passed since last update.

void value expression メモ

Last updated at Posted at 2014-12-18

void value expression は、返す値がない式をreturnしたり代入したりすると返されるエラーだそうです。

次のコードで void value expression がでて少し迷いました。

return 123 <= 456 and 456 <= 789

以下のようにすることで回避できました。

return (123 <= 456 and 456 <= 789)

ちなみに

これはエラーを返さないみたいです。

return 123 <= 456 && 456 <= 789

これは、Rubyのandと&&の優先度の違いによるもののようです。
andの方が低いです。
=> http://docs.ruby-lang.org/ja/1.9.3/doc/spec=2foperator.html#and

5
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4