14
11

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.

rubyで3つの値が同一かを確認する方法

Last updated at Posted at 2016-05-17

3つの値が同一かを確認する方法

他にいいやり方があると思いますが、自分のやり方です。

a = 1
b = 1
c = 1

[a, b, c].uniq.count == 1

配列にして、重複を削除してから個数を数えます。

これでtrue or falseで値が返って来ます。

もっといい方法があると思うのですが、ご存知の方がいたら、教えて下さい。

14
11
6

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
14
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?