Ruby is so elegant that I fidng myself wanting to write similarly,.
jump and shout unless someone.sleeping?
Ruby isn’t English, though.
Just wish it’s was interpreted as such
It is; it’s just that puts returns nil, so it doesn’t pass through the
and gate. I don’t think the word “and” just to mean “and then execute
this” would be very useful.
On Thu, Dec 4, 2008 at 11:28 PM, David A. Black [email protected]
wrote:
I do not think highly of the following code in general, but if this is
about some literal programming idea it might come in handy. Children
just do not use it when home alone
irb(main):010:0> class Object
irb(main):011:1> def and &blk
irb(main):012:2> blk.call
irb(main):013:2> end
irb(main):014:1> end
=> nil
irb(main):015:0> puts( 42 ).and { puts 42 }.and { puts 42 }
42
42
42
Cheers
R.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.