るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

Kernel.#block_given? -> bool (24313.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.
check #=> Block isn't given.
//}...

Kernel.#iterator? -> bool (6113.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.
check #=> Block isn't given.
//}...

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (206.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 (206.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}...