0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

文字列の引数とブロックの引数を同時に渡させる

Posted at

文字列の引数とブロックの引数を同時に渡させる

irb(main):001* def greeting(hi)
irb(main):002*   puts hi + "おはよう"
irb(main):003*   yield
irb(main):004*   puts "こんばんは"
irb(main):005> end
=> :greeting
irb(main):006* greeting("hogehoge") do
irb(main):007*   puts "こんにちは"
irb(main):008> end
hogehogeおはよう
こんにちは
こんばんは
=> nil
irb(main):018* def greeting(hi)
irb(main):019*   puts hi + "おはよう"
irb(main):020*   yield "こんにちは"
irb(main):021*   puts "こんばんは"
irb(main):022> end
=> :greeting
irb(main):023* greeting("hogehoge") do |i|
irb(main):024*   puts "#{i}"
irb(main):025> end
hogehogeおはよう
こんにちは
こんばんは
=> nil
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?