From: "Marcel Molina Jr." Date: 2004-09-16T12:18:18+09:00 Subject: Re: Ex-Perl coders: Howz it feel to convert to Ruby? On Thu, Sep 16, 2004 at 09:24:49AM +0900, ChrisO wrote: > Phil Tomson wrote: > > >In article <20040915185304.GD4046@lb.tenfour>, > >Dick Davies wrote: > > > >>* Phil Tomson [0909 19:09]: > >> > >> > >>>.... You know all of the methods that will operate on a particular > >>>object of a certain class (or you can easily find out) and there were > >>>more methods available on builtin classes (for example, look at all of > >>>the methods available on Array objects and compare with functions > >>>available in Perl to operate on @list objects). > >> > >>That's something that shouldn't be overlooked - > >> > >>when I went back to perldoc after maybe 9 months away from Perl I had > >>major problebs remembering the right function to do a particular bit > >>of manipulation on a Hash. perldoc -f isn't much use without a method > >>name, > >>and even Google is only useful if can say what you want :) > >> > >>With Ruby it was just 'ri Hash;ri Enumerable' to see all the methods > >>that worked on a Hash. > >> > > > > > >Or in irb: > > > Array.methods.sort > >=> ["&", "*", "+", "-", "<<", "<=>", "==", "===", "=~", "[]", "[]=", > >"__id__", "__send__", "all?", "any?", "assoc", "at", "class", "clear", > >"clone", "collect", "collect!", "compact", "compact!", "concat", "delete", > >"delete_at", "delete_if", "detect", "display", "dup", "each", > >"each_index", "each_with_index", "empty?", "entries", "eql?", "equal?", > >"extend", "fetch", "fill", "find", "find_all", "first", "flatten", > >"flatten!", "freeze", "frozen?", "grep", "hash", "id", "include?", > >"index", "indexes", "indices", "inject", "insert", "inspect", > >"instance_eval", "instance_of?", "instance_variable_get", > >"instance_variable_set", "instance_variables", "is_a?", "join", > >"kind_of?", "last", "length", "map", "map!", "max", "member?", "method", > >"methods", "min", "nil?", "nitems", "object_id", "pack", "partition", > >"pop", "private_methods", "protected_methods", "public_methods", "push", > >"rassoc", "reject", "reject!", "replace", "respond_to?", "reverse", > >"reverse!", "reverse_each", "rindex", "select", "send", "shift", > >"singleton_methods", "size", "slice", "slice!", "sort", "sort!", > >"sort_by", "taint", "tainted?", "to_a", "to_ary", "to_s", "transpose", > >"type", "uniq", "uniq!", "unshift", "untaint", "values_at", "zip", "|"] > > > > More "Wow!" You can't do this in Perl (unless you call in another CPAN > module to pick apart another module. Hardly compariable.) > > I becoming quite glad I've started this discussion. I'm thinking I'm > just about taken in with this. Beautiful. also if your .irbrc includes "require 'irb/completion'" you can tab complete methods: e.g. >> "The Boat Arrived!".s .scan .sort .sub .select .sort_by .sub! .send .split .succ .singleton_methods .squeeze .succ! .size .squeeze! .sum .slice .strip .swapcase .slice! .strip! .swapcase! >> "The Boat Arrived!".sum - 1 => 1492 marcel -- Marcel Molina Jr.