вторник, ноября 06, 2007

Giles Bowkett: IRB: What Was That Method Again?

Giles Bowkett: IRB: What Was That Method Again?
why should someone bother adding just another method to do stuff that is easily done with existing methods ?
"any arbitrary string".methods.grep("ch")

2 комментария:

Ryan Davis комментирует...

personally I prefer:

"str".ch TAB TAB

Unknown комментирует...

This works only if:

1. You have a plugin for IRB that does autocompletion =)
2. You know method prefix.

With grep you can find names that contain some word (not start with some word):

"abc".methods.grep(/index/)
# => ["index", "rindex", "each_with_index"]

"abc".methods.grep(/strip/)
=> ["lstrip!", "strip", "rstrip!", "lstrip", "rstrip", "strip!"]