| 情報学部 | 菅沼ホーム | 目次 | 索引 |
block = Proc.new { |a, b, c| p [a, b, c] }
block.call(1, 2, 3) # [1, 2, 3] を出力
block.call(1, 2) # [1, 2, nil]
block.call(1, 2, 3, 4) # [1, 2, 3] を出力
def test &block
block.call(1, 2, 3)
end
test { |a, b, c| p [a, b, c] } # [1, 2, 3] を出力
def test &block
yield(1, 2, 3)
end
test { |a, b, c| p [a, b, c] } # [1, 2, 3] を出力
def test
block = Proc.new
block.call(1, 2, 3)
end
test { |a, b, c| p [a, b, c] } # [1, 2, 3] を出力
def test
yield(1, 2, 3)
end
test { |a, b, c| p [a, b, c] } # [1, 2, 3] を出力
| 情報学部 | 菅沼ホーム | 目次 | 索引 |