0
0

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 3 years have passed since last update.

[Ruby] uniqメソッド

Posted at

はじめに

面接でかなり撃沈して、何もやる気起きませんが、何か学びを一つ得てから寝ます。
最近メソッドの記事ばかりですが、今回はuniqメソッドを記事にいたします。

uniqメソッド

uniqメソッドは配列の要素に同じ要素が二つ以上存在していれば一つにしてくれます。

array = [1, 1, 2, 3, 4, 5, 5, 6]
array.uniq
=> [1, 2, 3, 4, 5, 6]

uniq!とすれば破壊的に使用することも可能です。

0
0
0

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?