943,670 Members | Top Members by Rank

Ad:
  • Ruby Discussion Thread
  • Unsolved
  • Views: 2826
  • Ruby RSS
Oct 14th, 2008
0

for loops in Ruby

Expand Post »
I am trying to search through a string to find the number of occurences of a substring. I am doing this for all the strings in an array of strings. I only have figured out the while loops so far. How can I traverse through an array of strings using a for loop?
Similar Threads
Reputation Points: 11
Solved Threads: 2
Light Poster
kinger29 is offline Offline
35 posts
since Mar 2008
Oct 27th, 2008
0

Re: for loops in Ruby

You don't need to use a loop if you take advantage of the API. If you take the length of the array returned "scanning" for your substring with String#scan, you will have number of occurrences of that substring.
Reputation Points: 32
Solved Threads: 10
Junior Poster in Training
destin is offline Offline
94 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Ruby Forum Timeline: Ruby Binary Search Tree
Next Thread in Ruby Forum Timeline: destructors in ruby





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC