るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

検索結果

<< 1 2 > >>

Kernel.#block_given? -> bool (18113.0)

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

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

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

Kernel.#iterator? -> bool (3013.0)

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

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

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

クラス/メソッドの定義 (18.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...義][ruby]{
# yield を使う
def foo
# block_given? は、メソッドがブロックを渡されて
# 呼ばれたかどうかを判定する組み込み関数
if block_given?
yield(1,2)
end
end

# Proc.new を使う
def bar
if block_given?
Proc.new.call(1,2) # proc.call(1,2)...
...があります。

//emlist[][ruby]{
defined? yield
//}

yield の呼び出しが可能なら真(文字列 "yield")を返します。
Kernel.#block_given? と同様にメソッドがブロック付きで呼ばれたか
を判断する方法になります。

//emlist[][ruby]{
defined? super
//}

s...

static VALUE rb_f_block_given_p(void) (16.0)

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

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

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (6.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(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}...

絞り込み条件を変える

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (6.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(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}...

Enumerator::Lazy#to_enum(method = :each, *args) -> Enumerator::Lazy (6.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(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}...

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (6.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(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}...

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

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

...(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n...

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

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

...(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n...

絞り込み条件を変える

<< 1 2 > >>