BrainLikeADullPencil
BrainLikeADullPencil

Reputation: 11673

Ruby: method finder gem example

I found this great gem 'method finder' that I'm trying to use to help improve my understanding of Ruby, problem is that I don't really get it. It gives this example from the docs. The method 'unknown' is supposed to replace whatever method will give the result in the surrounding code, but what is this example telling us?

>> 10.find_method { |n| n.unknown(3) == 1 }
=> ["Fixnum#%", "Fixnum#<=>", "Fixnum#>>", "Fixnum#[]", "Integer#gcd", "Fixnum#modulo", "Numeric#remainder"]

Upvotes: 3

Views: 128

Answers (1)

Gareth
Gareth

Reputation: 138200

It's telling you exactly what you asked it for: all the methods on 10 that return 1 when passed 3:

>> 10 % 3
 => 1 
>> 10 <=> 3
 => 1 
>> 10 >> 3
 => 1 
>> 10[3]
 => 1 
>> …

Upvotes: 4

Related Questions