drop_whileの読み方

drop_whileの読み方

rubyで利用されるメソッドの1つである「drop_while」の読み方を掲載してます。

読み⽅

ドロップ・ワイル」と読みます。

英訳

「while」は「の間」という意味があります。

drop_whileとは

rubyで、元の値を変更せずに配列を指定した条件が続くまで値を削除する際に、使用します。

arr = arr=[0, 1, 2, 3, 4, 5, 6]

p arr.drop_while {|x| x <= 2}
# [3, 4, 5, 6]

p arr
# [1, 2, 3, 4, 5, 6]