Proc problem

<meta http-equiv="content-type" content="text/html; 

charset=ISO-8859-1">

Hello,

Im trying to do this exercise :

  1. Create a method, greeter, that takes no arguments and yields to a block.
  2. Create a Proc, phrase, that puts "Hello there!". Pass this to greeter instead of a block. (Don't forget to pass &phrase instead of just phrase!)

Till now I have this :

def greeter
    yield
end

phrase = Proc.new do
    puts "Hello there!"
end

But I do not see where and how I must use the &phrase  ?
Can someone help me figure out how to solve this ?

Roelof


On Wed, Nov 19, 2014 at 1:16 PM, Roelof W. [email protected] wrote:

def greeter
yield
end

phrase = Proc.new do
puts “Hello there!”
end

But I do not see where and how I must use the &phrase ?
Can someone help me figure out how to solve this ?

It’s all in the description of task 2. You pass something to a method
but…

Kind regards

robert

greeter &phrase

I recommend you to read about blocks and Procs. This link may be useful
but
there should be better ones:
http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls#The_ampersand_.28.26.29

2014-11-19 9:16 GMT-03:00 Roelof W. [email protected]:

On Wed, Nov 19, 2014 at 1:28 PM, Juanjo C. [email protected] wrote:

I think it’s not so helpful to just post the answer when someone is
trying to learn.

Cheers

robert

Yep. I found it myself that the answer is greeter(&phrase)

Roelof


Juanjo C. schreef op 19-11-2014 13:28:
greeter &phrase

I recommend you to read about blocks and Procs. This link may be useful but there should be better ones:??http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls#The_ampersand_.28.26.29

2014-11-19 9:16 GMT-03:00 Roelof W. <[email protected]>:
Hello,

Im trying to do this exercise :

  1. Create a method, greeter, that takes no arguments and yields to a block.
  2. Create a Proc, phrase, that puts "Hello there!". Pass this to greeter instead of a block. (Don't forget to pass &phrase instead of just phrase!)

Till now I have this :

def greeter
?????? yield
end

phrase = Proc.new do
?????? puts "Hello there!"
end

But I do not see where and how I must use the &phrase?? ?
Can someone help me figure out how to solve this ?

Roelof





--
Juanjo C.
Mi primer novela ya se puede conseguir en: http://www.juanjoconti.com.ar/xolopes

Did you read the article I pointed out? If you’re learning, instead of
just
make the code work, you should worry to understand why it did work.

Greets,

PS: Sorry Robert about the direct response.

2014-11-19 9:48 GMT-03:00 Roelof W. [email protected]:

Yes. I did. That's whty I figured the solution myself.

Roelof

Juanjo C. schreef op 19-11-2014 13:55:
Did you read the article I pointed out? If you're learning, instead of just make the code work, you should worry to understand why it did work.

Greets,

PS: Sorry Robert about the direct response.

2014-11-19 9:48 GMT-03:00 Roelof W. <[email protected]>:
Yep. I found it myself that the answer is greeter(&phrase)

Roelof


Juanjo C. schreef op 19-11-2014 13:28:
greeter &phrase

I recommend you to read about blocks and Procs. This link may be useful but there should be better ones:??http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls#The_ampersand_.28.26.29

2014-11-19 9:16 GMT-03:00 Roelof W. <[email protected]>:
Hello,

Im trying to do this exercise :

  1. Create a method, greeter, that takes no arguments and yields to a block.
  2. Create a Proc, phrase, that puts "Hello there!". Pass this to greeter instead of a block. (Don't forget to pass &phrase instead of just phrase!)

Till now I have this :

def greeter
?????? yield
end

phrase = Proc.new do
?????? puts "Hello there!"
end

But I do not see where and how I must use the &phrase?? ?
Can someone help me figure out how to solve this ?

Roelof





--
Juanjo C.
Mi primer novela ya se puede conseguir en: http://www.juanjoconti.com.ar/xolopes




--
Juanjo C.
Mi primer novela ya se puede conseguir en: http://www.juanjoconti.com.ar/xolopes