# String count method in 1.9

**URL:** <https://www.ruby-forum.com/t/string-count-method-in-1-9/126693>\
**Category:** Ruby\
**Created:** [January 21, 2008, 12:50pm UTC](https://www.ruby-forum.com/t/string-count-method-in-1-9/126693 "2008-01-21T12:50:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![indianguru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3bc359/32.png) [@indianguru](https://www.ruby-forum.com/u/indianguru)\
**Post date:** [January 21, 2008, 12:50pm UTC](https://www.ruby-forum.com/t/string-count-method-in-1-9/126693/1 "2008-01-21T12:50:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![indianguru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3bc359/32.png) [@indianguru](https://www.ruby-forum.com/u/indianguru)\
**Post date:** [January 21, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/string-count-method-in-1-9/126693/2 "2008-01-21T14:07:34Z")

</div>

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 🙂
