On 6/18/06, Gautam D. [email protected] wrote:
irb(main):002:0>
What am I doing wrong? Do I need to include a module? If so, how?
Nothing, the documentation is wrong, I used irb to check again
irb(main):007:0> Array.new.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”, “|”]
irb(main):008:0>
and there just is no abbrev method.
However you are right with the module idea, quite impressive for a
newbie
require “abbrev”
=> true
irb(main):002:0> Array.new.methods.sort
=> [“&”, “*”, “+”, “-”, “<<”, “<=>”, “==”, “===”, “=~”, “[]”, “[]=”,
“id”, “send”, “abbrev”, “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”, “|”]
[“ala”, “ada”, “b”, “broad”, “crypt”].abbrev
=> {“ala”=>“ala”, “al”=>“ala”, “b”=>“b”, “broa”=>“broad”,
“crypt”=>“crypt”,
“c”=>“crypt”, “ad”=>“ada”, “cr”=>“crypt”, “br”=>“broad”,
“broad”=>“broad”,
“cryp”=>“crypt”, “ada”=>“ada”, “bro”=>“broad”, “cry”=>“crypt”}
irb(main):004:0>
And you are set for the Ruby Q., good luck
Robert
Thank you,
Gautam
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.