Fishing in Ruby


#1

sea =<<END_OF_SEA

<}}}}> ><}}}}> ><}}}}>
<}}}}
>
<}}}}> ><}}}}>
<}}}}*>

END_OF_SEA

fish_caught = sea.scan(%><}}}}*>)
“I got #{fish_caught.size} fish!” # => “I got 7 fish!”

Please don’t overfish.

– Fisherman


#2

Hi –

On Fri, 28 Apr 2006, A Fisherman wrote:

“I got #{fish_caught.size} fish!” # => “I got 7 fish!”
But does it scale?

David


David A. Black (removed_email_address@domain.invalid)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

“Ruby for Rails” PDF now on sale! http://www.manning.com/black
Paper version coming in early May!


#3

Are you doing this for the halibut? ha!

-A


#4

unknown wrote:

“I got #{fish_caught.size} fish!” # => “I got 7 fish!”
But does it scale?

Now THAT was a groaner if I ever saw one. :wink: hehehe

Pistos


#5

Pistos C. wrote:

A Fisherman wrote:

fish_caught = sea.scan(%><}}}}*>)

Just as I thought: Your code doesn’t run. :wink:

irb(main):088:0> fish_caught = sea.scan(%><}}}}*>)
irb(main):089:1"

This works, though:

fish_caught = sea.scan("><}}}}*>")

/me supposes he’s taking this far too seriously…

IRB can’t handle the fish. It runs reel well using regular ruby command.


#6

so your not fishing off the same platform?


#7

A Fisherman wrote:

fish_caught = sea.scan(%><}}}}*>)

Just as I thought: Your code doesn’t run. :wink:

irb(main):088:0> fish_caught = sea.scan(%><}}}}*>)
irb(main):089:1"

This works, though:

fish_caught = sea.scan("><}}}}*>")

/me supposes he’s taking this far too seriously…

Pistos


#8

On 4/27/06, Daniel B. removed_email_address@domain.invalid wrote:

To: ruby-talk ML

Posted via http://www.ruby-forum.com/.

I believe he was trolling

pth


#9

Perhaps the original poster was just fishing for compliments.


#10

A Fisherman wrote:

Pistos C. wrote:

fish_caught = sea.scan(%><}}}}*>)
IRB can’t handle the fish. It runs reel well using regular ruby command.

Can someone explain what’s happening with the line, then? Is it using
the ‘>’ as the delimiter? So it’s sort of chopping off the “snout” of
each fish?

Pistos