るりまサーチ

最速Rubyリファレンスマニュアル検索!
77件ヒット [1-77件を表示] (0.122秒)
トップページ > クエリ:i[x] > クエリ:block_given?[x]

別のキーワード

  1. socket ip_block_source
  2. socket mcast_block_source
  3. openssl block_size
  4. digest block_length
  5. psych block

ライブラリ

クラス

モジュール

キーワード

検索結果

Kernel.#block_given? -> bool (24213.0)

メソッドにブロックが与えられていれば真を返します。

...返します。

i
terator? は (ブロックが必ずイテレートするとはいえないので)推奨されていないの
block_given? を使ってください。

//emlist[例][ruby]{
def check
i
f block_given?
puts "Block is given."
else
puts "Block isn't given."
end
end...
...check{} #=> Block is given.
check #=> Block isn't given.
//}...

Kernel.#iterator? -> bool (9113.0)

メソッドにブロックが与えられていれば真を返します。

...返します。

i
terator? は (ブロックが必ずイテレートするとはいえないので)推奨されていないの
block_given? を使ってください。

//emlist[例][ruby]{
def check
i
f block_given?
puts "Block is given."
else
puts "Block isn't given."
end
end...
...check{} #=> Block is given.
check #=> Block isn't given.
//}...

static VALUE rb_f_block_given_p(void) (6116.0)

block_given? の実体。 現在評価中の (Ruby で実装された) メソッドに対して ブロックが与えられていたら真。

...
block_given?
の実体。
現在評価中の (Ruby で実装された) メソッドに対して
ブロックが与えられていたら真。...

Object#enum_for(method = :each, *args) -> Enumerator (12.0)

Enumerator.new(self, method, *args) を返します。

...た場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

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

enu...
...# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はこ...
...epeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'he...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (12.0)

Enumerator.new(self, method, *args) を返します。

...た場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

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

enu...
...# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はこ...
...epeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'he...

絞り込み条件を変える

Object#to_enum(method = :each, *args) -> Enumerator (12.0)

Enumerator.new(self, method, *args) を返します。

...た場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

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

enu...
...# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はこ...
...epeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'he...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (12.0)

Enumerator.new(self, method, *args) を返します。

...た場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

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

enu...
...# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はこ...
...epeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'he...