jonsanders101 jonsanders101 - 23 days ago 7
Ruby Question

How to tell in which version of Ruby a method was first introduced?

In the official Ruby documentation or elsewhere, is there an easy way of seeing in which version of Ruby a given method was first introduced to the language?

I haven't found such a resource and it seems it would be obviously useful.

Answer Source

You could try checking out changelogs here https://github.com/ruby/ruby/blob/trunk/doc but it looks like they skipped few ;)

The only way I can think of is to have all major version binaries, and execute code on them to see if works. If you were looking for Hash#fetch you could run ruby -e 'Hash.new.fetch(0, 0)' each version which returns 0 will have it implemented, others means some error. You could use rvm for that.

You could automatize it with git bisect. But it would have to compile ruby binary for each check, and some dependencies could have changed so I would not expect it to work on first try :D