Proc problem

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

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 Wobben <r.wobben@home.nl>:

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 Conti
Mi primer novela ya se puede conseguir en:

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

Kind regards

robert

···

On Wed, Nov 19, 2014 at 1:16 PM, Roelof Wobben <r.wobben@home.nl> wrote:

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 ?

--
[guy, jim].each {|him| remember.him do |as, often| as.you_can - without end}
http://blog.rubybestpractices.com/

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

  Roelof

  Juanjo Conti 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 Wobben

r.wobben@home.nl:

Hello,

          Im trying to do this exercise :
  1. Create a method, greeter , that takes
    no arguments and yield s 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 Conti

        Mi primer novela ya se puede conseguir en: [http://www.juanjoconti.com.ar/xolopes](http://www.juanjoconti.com.ar/xolopes)

<snip/>

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

Cheers

robert

···

On Wed, Nov 19, 2014 at 1:28 PM, Juanjo Conti <jjconti@gmail.com> wrote:

--
[guy, jim].each {|him| remember.him do |as, often| as.you_can - without end}
http://blog.rubybestpractices.com/

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 Wobben <r.wobben@home.nl>:

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

Roelof

Juanjo Conti 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:
Ruby Programming/Syntax/Method Calls - Wikibooks, open books for an open world

2014-11-19 9:16 GMT-03:00 Roelof Wobben <r.wobben@home.nl>:

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 Conti
Mi primer novela ya se puede conseguir en:
http://www.juanjoconti.com.ar/xolopes

--
Juanjo Conti
Mi primer novela ya se puede conseguir en:

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

  Roelof

  Juanjo Conti 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 Wobben

r.wobben@home.nl:

            Yep. I found it myself that the answer is

greeter(&phrase)

            Roelof





            Juanjo Conti 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 Wobben r.wobben@home.nl:

                        Hello,




                        Im trying to do this exercise :
  1. Create a method, greeter ,
    that takes no arguments and yield s
    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 Conti

                      Mi primer novela ya se puede conseguir en: [http://www.juanjoconti.com.ar/xolopes](http://www.juanjoconti.com.ar/xolopes)


Juanjo Conti

        Mi primer novela ya se puede conseguir en: [http://www.juanjoconti.com.ar/xolopes](http://www.juanjoconti.com.ar/xolopes)