8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

! と not では結合強度が違う

Last updated at Posted at 2013-02-22

ついつい ! って見落としがちなので not で書きたくなる時ってありますよね!!

!hoge && foo
あー 読みにくいなぁ……
not hoge && foo
にしよう!!

とかやってしまうとどうなるのかというと……

[1] pry(main)> !true && false
=> false
[2] pry(main)> not true && false
=> true

_人人人人人人人_
> 突然の true <
 ̄Y^Y^Y^Y^Y^Y ̄

わかりやすくカッコで括るとこんな感じってことですね!!

[3] pry(main)> (!true) && false
=> false
[4] pry(main)> not (true && false)
=> true

いやぁ…… 嵌りそう><

8
8
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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?