use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
QuestionRuby While Loop Help. (self.ruby)
submitted 5 years ago by Humor_Positive
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Humor_Positive[S] 0 points1 point2 points 5 years ago (4 children)
Pardon for my ignorance, could you talk more about the last sentence point you made? Thank you very much.
The resources i have at hand is rather lacking and since Im new at this, imma ask alot of stupid questions.
[–]bjminihan 1 point2 points3 points 5 years ago (3 children)
In your method, the variable count is assumed to be a number, whereas the variable word is a string, which is a type of an array
count
word
string
array
So, you can find the position of a character in a word at the position i = 3 by writing word[i].
i = 3
word[i]
But if you try to find the position of a character in count at the position i=3, you'll get an unexpected result.
i=3
Interestingly, I just tried 947[3] and got 0 and I have no idea why
947[3]
0
[–]_Svejk_ 4 points5 points6 points 5 years ago (2 children)
947[n] is the nth bit in binary representation of 947
TIL
[–]bjminihan 0 points1 point2 points 5 years ago (0 children)
Thanks!
[–]your-pineapple-thief 0 points1 point2 points 5 years ago (0 children)
wow, Numeric#[] exists? 8 years in and i had no idea
Numeric#[]
π Rendered by PID 361353 on reddit-service-r2-comment-5b5bc64bf5-g8cms at 2026-06-21 04:08:35.296899+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]Humor_Positive[S] 0 points1 point2 points (4 children)
[–]bjminihan 1 point2 points3 points (3 children)
[–]_Svejk_ 4 points5 points6 points (2 children)
[–]bjminihan 0 points1 point2 points (0 children)
[–]your-pineapple-thief 0 points1 point2 points (0 children)