別のキーワード
検索結果
先頭5件
-
String
# *(times) -> String (18126.0) -
文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。
...self を times 回繰り返した新しい文字列
@raise ArgumentError 引数に負数を指定したときに発生します。
//emlist[例][ruby]{
p "str" * 3 # => "strstrstr"
str = "abc"
p str * 4 # => "abcabcabcabc"
p str * 0 # => ""
p str # => "abc" (変化なし)
//}... -
Array
# *(times) -> Array (18115.0) -
配列の内容を times 回 繰り返した新しい配列を作成して返します。 値はコピーされないことに注意してください。
...or 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
@raise ArgumentError 引数に負の数を指定した場合に発生します。
//emlist[例][ruby]{
p [1, 2, 3] * 3 #=> [1, 2, 3, 1, 2, 3, 1, 2, 3]
//}... -
Array
# *(sep) -> String (18110.0) -
指定された sep を間にはさんで連結した文字列を生成して返します。Array#join(sep) と同じ動作をします。
...ep) と同じ動作をします。
@param sep 文字列を指定します。
文字列以外のオブジェクトを指定した場合は to_str メソッドによ
る暗黙の型変換を試みます。
//emlist[例][ruby]{
p [1,2,3] * ","
# => "1,2,3"
//}
@see Array#join... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (246.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......ise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*va......l|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (246.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......ise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*va......l|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (225.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...== option引数の概要
Hash を options として渡すことで、起動される子プロセスの
* プロセスグループ
* resource limit
* カレントディレクトリ
* umask
* 子プロセスでのリダイレクト
などを変更できます。環境変数のクリアなど......す。
* 単一のファイルデスクリプタ
* ファイルデスクリプタの配列
配列を渡すことで複数のファイルデスクリプタを同時にリダイレクトできます。
Hash の値(親プロセス側)には以下のいずれかが指定できます。
* 単一......のファイルデスクリプタ
* リダイレクト先のファイル名文字列
* [リダイレクト先のファイル名文字列]、配列の要素にすることで
File::Constants::RDONLY でファイルを開いてリダイレクトします。
* [リダイレクト先のファ... -
Kernel
. # spawn(program , *args) -> Integer (225.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...== option引数の概要
Hash を options として渡すことで、起動される子プロセスの
* プロセスグループ
* resource limit
* カレントディレクトリ
* umask
* 子プロセスでのリダイレクト
などを変更できます。環境変数のクリアなど......す。
* 単一のファイルデスクリプタ
* ファイルデスクリプタの配列
配列を渡すことで複数のファイルデスクリプタを同時にリダイレクトできます。
Hash の値(親プロセス側)には以下のいずれかが指定できます。
* 単一......のファイルデスクリプタ
* リダイレクト先のファイル名文字列
* [リダイレクト先のファイル名文字列]、配列の要素にすることで
File::Constants::RDONLY でファイルを開いてリダイレクトします。
* [リダイレクト先のファ... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (218.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...at(n)
raise ArgumentError if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end
else
to_enum(:repeat, n)
end
end
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).f... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (218.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...at(n)
raise ArgumentError if n < 0
if block_given?
each do |*val|
n.times { yield *val }
end
else
to_enum(:repeat, n)
end
end
end
r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]
r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).f... -
Array
# pack(template) -> String (152.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...した文字列を返します。
テンプレートは
型指定文字列とその長さ(省略時は1)を並べたものです。長さと
して * が指定された時は「残りのデータ全て」の長さを
表します。型指定文字は以下で述べる pack テンプレート文字......文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けることができます。「長さ」の代わりに`*'とすることで「残り全て」
を表すこともできます。
長さの意味はテンプレート文字により異なりますが大抵......k("a*") # => "abc"
["abc"].pack("a4") # => "abc\x00"
"abc\0".unpack("a4") # => ["abc\x00"]
"abc ".unpack("a4") # => ["abc "]
//}
: A
ASCII文字列(スペースを詰める/後続するヌル文字やスペースを削除)
//emlist[][ruby]{
["abc"].pack("A") # => "a"
["abc"].pack("A*")...