megas
megas

Reputation: 21791

Can't understand yield

In some project i met this code:

erb = yield.src

I can't understand what the src method is doing and how it's possible to chain to yield method.

Thanks

Upvotes: 1

Views: 220

Answers (1)

Shiv
Shiv

Reputation: 8412

As far as I understand yield would return an object which has the instance method src defined on it

something like this

def foo
  p yield.class
end

foo do 
 1
end  

This will print Fixnum

Upvotes: 1

Related Questions