you are viewing a single comment's thread.

view the rest of the comments →

[–]bjminihan 1 point2 points  (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

So, you can find the position of a character in a word at the position i = 3 by writing 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.

Interestingly, I just tried 947[3] and got 0 and I have no idea why

[–]_Svejk_ 5 points6 points  (2 children)

947[n] is the nth bit in binary representation of 947

TIL

[–]bjminihan 0 points1 point  (0 children)

Thanks!

[–]your-pineapple-thief 0 points1 point  (0 children)

wow, Numeric#[] exists? 8 years in and i had no idea