1
0

More than 1 year has passed since last update.

takeメソッドについて

Posted at

takeメソッド

先頭から任意の数の要素を取得
使い方は下記の通り。

(%w使用し、配列の要素をスペースで区切り配列を作成する)

irb(main):040:0> %w(Ruby Python Java C Smalltalk Brainfuck)
=> ["Ruby", "Python", "Java", "C", "Smalltalk", "Brainfuck"]

(takeメソッドで先頭から3つの要素を取得)

irb(main):041:0> %w(Ruby Python Java C Smalltalk Brainfuck).take(3)
=> ["Ruby", "Python", "Java"]
1
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
1
0