るりまサーチ

最速Rubyリファレンスマニュアル検索!
430件ヒット [1-100件を表示] (0.076秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

String.new(string = "") -> String (26133.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with
_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with
_encoding.encoding == Encoding::UTF_8 # => true
String.new("test", encoding:...

String.new(string = "", encoding: string.encoding, capacity: 127) -> String (26133.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with
_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with
_encoding.encoding == Encoding::UTF_8 # => true
String.new("test", encoding:...

String.new(string = "", encoding: string.encoding, capacity: 63) -> String (26133.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with
_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with
_encoding.encoding == Encoding::UTF_8 # => true
String.new("test", encoding:...

String.new(string = "", encoding: string.encoding, capacity: string.bytesize) -> String (26133.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with
_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with
_encoding.encoding == Encoding::UTF_8 # => true
String.new("test", encoding:...

String.new(string = "") -> String (26126.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...by]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with
_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with
_encoding.encoding == Encoding::UTF_8 #...

絞り込み条件を変える

String.new(string = "", encoding: string.encoding) -> String (26126.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...by]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text) # => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with
_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with
_encoding.encoding == Encoding::UTF_8 #...

Data#with(**kwargs) -> Data (26119.0)

self をコピーしたオブジェクトを返します。

...][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5) # => #<data Dog name="Fred", age=5>
dog2 = dog1.with(age: 6) # => #<data Dog name="Fred", age=6>
p dog1 # => #<data Dog name="Fred", age=5>
dog3 = dog1.with(type: "Terrier") # => ArgumentError (unknown keyword:...

Enumerable#each_with_index(*args) -> Enumerator (14138.0)

要素とそのインデックスをブロックに渡して繰り返します。

...た場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args...
...each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

Enumerable#each_with_index(*args) {|item, index| ... } -> self (14138.0)

要素とそのインデックスをブロックに渡して繰り返します。

...た場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args...
...each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

Enumerator#with_index(offset = 0) -> Enumerator (14138.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

.../emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]

require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|", 1]...
...にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...

絞り込み条件を変える

Enumerator#with_index(offset = 0) {|(*args), idx| ... } -> object (14138.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

.../emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]

require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|", 1]...
...にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...

Enumerator#with_object(obj) -> Enumerator (14132.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

...

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}...
...@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object...

Enumerator#with_object(obj) {|(*args), memo_obj| ... } -> object (14132.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

...

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}...
...@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object...

Thread#report_on_exception=(newstate) (8118.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...ド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on...
...ead:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception =...
<< 1 2 3 ... > >>