[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

String count method in 1.9

Satish Talim

1/21/2008 11:50:00 AM

[Note: parts of this message were removed to make it a legal post.]

As per the Ruby documentation,
string.count(character_set1,character_set2)first takes the
intersection of
character_set1 and character_set2 and then counts the number of times each
character from the resulting intersection occurs in string.

The program:
a = 'hooooooooooll'
puts a.count "lo" "o"

displays 10 in irb but displays 12 in Ruby 1.9. Why?

1 Answer

Satish Talim

1/21/2008 1:07:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

Damn silly of me, to miss out the , between the two parameters. I'll
attribute it to my high fever but still can't leave aside Ruby :)

On Jan 21, 2008 5:19 PM, Satish Talim <satish.talim@gmail.com> wrote:

> As per the Ruby documentation, string.count(character_set1,character_set2)first takes the intersection of
> character_set1 and character_set2 and then counts the number of times each
> character from the resulting intersection occurs in string.
>
> The program:
> a = 'hooooooooooll'
> puts a.count "lo" "o"
>
> displays 10 in irb but displays 12 in Ruby 1.9. Why?
>