D
David Unric
Hi,
I've discovered some strange behaviour in Interactive Ruby shell (IRB) I
cann't explain myself. It manifests only with Wirble enhacement with
colorization enabled.
=> [:!, :!, :!, :, :, :=>, :, :, :, :, :, :__id__, :__send__, :allocate,
:ancestors, :autoload, :autoload?, :class, :class_eval, :class_exec,
:class_variable_defined?, :class_variable_get, :class_variable_set,
:class_variables, :clone, :const_defined?, :const_get, :const_missing,
:const_set, :constants, :define_singleton_method, :display, :dup,
:enum_for, :eql?, :equal?, :extend, :freeze, :frozen?, :hash, :include?,
:included_modules, :initialize_clone, :initialize_dup, :inspect,
:instance_eval, :instance_exec, :instance_method, :instance_methods,
:instance_of?, :instance_variable_defined?, :instance_variable_get,
:instance_variable_set, :instance_variables, :is_a?, :kind_of?, :method,
:method_defined?, :methods, :module_eval, :module_exec, :name, :nesting,
:new, :nil?, bject_id, o, oc, retty_inspect, retty_print,
retty_print_cycle, retty_print_inspect,
retty_print_instance_variables, rivate_class_method,
rivate_instance_methods, rivate_method_defined?, rivate_methods,
rotected_instance_methods, rotected_method_defined?,
rotected_methods, ublic_class_method, ublic_instance_method,
ublic_instance_methods, ublic_method, ublic_method_defined?,
ublic_methods, ublic_send, :remove_class_variable, :respond_to?,
:respond_to_missing?, :ri, :send, :singleton_class, :singleton_methods,
:superclass, :taint, :tainted?, :tap, :to_enum, :to_s, :trust, :untaint,
:untrust, :untrusted?]
How can be the same symbols(names) different ? Can somebody explain ?
If I define my own array of symbols, method 'uniq' works as expected,
because the same symbols are discarded.
Can this be explained as a correct Ruby's behaviour or did I missed
something ?
Thanks.
David
I've discovered some strange behaviour in Interactive Ruby shell (IRB) I
cann't explain myself. It manifests only with Wirble enhacement with
colorization enabled.
=> [:!, :!, :!, :, :, :=>, :, :, :, :, :, :__id__, :__send__, :allocate,
:ancestors, :autoload, :autoload?, :class, :class_eval, :class_exec,
:class_variable_defined?, :class_variable_get, :class_variable_set,
:class_variables, :clone, :const_defined?, :const_get, :const_missing,
:const_set, :constants, :define_singleton_method, :display, :dup,
:enum_for, :eql?, :equal?, :extend, :freeze, :frozen?, :hash, :include?,
:included_modules, :initialize_clone, :initialize_dup, :inspect,
:instance_eval, :instance_exec, :instance_method, :instance_methods,
:instance_of?, :instance_variable_defined?, :instance_variable_get,
:instance_variable_set, :instance_variables, :is_a?, :kind_of?, :method,
:method_defined?, :methods, :module_eval, :module_exec, :name, :nesting,
:new, :nil?, bject_id, o, oc, retty_inspect, retty_print,
retty_print_cycle, retty_print_inspect,
retty_print_instance_variables, rivate_class_method,
rivate_instance_methods, rivate_method_defined?, rivate_methods,
rotected_instance_methods, rotected_method_defined?,
rotected_methods, ublic_class_method, ublic_instance_method,
ublic_instance_methods, ublic_method, ublic_method_defined?,
ublic_methods, ublic_send, :remove_class_variable, :respond_to?,
:respond_to_missing?, :ri, :send, :singleton_class, :singleton_methods,
:superclass, :taint, :tainted?, :tap, :to_enum, :to_s, :trust, :untaint,
:untrust, :untrusted?]
=> falseClass.methods.class => Array
defined? Class.methods => "method"
Class.methods.uniq.sort[0].class => Symbol
Class.methods.uniq.sort[1].class => Symbol
defined? (Class.methods.uniq.sort[0]) => "method"
defined? (Class.methods.uniq.sort[1]) => "method"
Class.methods.uniq.sort[0] == Class.methods.uniq.sort[1]
How can be the same symbols(names) different ? Can somebody explain ?
If I define my own array of symbols, method 'uniq' works as expected,
because the same symbols are discarded.
=> [ne, :two, :three, :four][ne,:two,:three,:two,:four,ne].uniq
Can this be explained as a correct Ruby's behaviour or did I missed
something ?
Thanks.
David