Mercurial > repos > other > SevenLanguagesInSevenWeeks
view 1-Ruby/object-all-things-2-irb.output @ 59:f86bb0d669be
Add a quick bit of maths code (list counting/summing)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 27 Sep 2017 20:19:01 +0100 |
parents | 8d46064c9afc |
children |
line wrap: on
line source
object-all-things-2.rb(main):001:0> #! /usr/bin/env ruby object-all-things-2.rb(main):002:0* object-all-things-2.rb(main):003:0* objects = [ 4, 3.14, 'Pi', 'π', false, true ] => [4, 3.14, "Pi", "π", false, true] object-all-things-2.rb(main):004:0> objects.each do |obj| object-all-things-2.rb(main):005:1* puts "#{obj} (#{obj.class})" object-all-things-2.rb(main):006:1> obj.methods.each { |method| puts " #{method}" } object-all-things-2.rb(main):007:1> end 4 (Fixnum) to_s inspect -@ + - * / div % modulo divmod fdiv ** abs magnitude == === <=> > >= < <= ~ & | ^ [] << >> to_f size bit_length zero? odd? even? succ integer? upto downto times next pred chr ord to_i to_int floor ceil truncate round gcd lcm gcdlcm numerator denominator to_r rationalize singleton_method_added coerce i +@ eql? remainder real? nonzero? step quo to_c real imaginary imag abs2 arg angle phase rectangular rect polar conjugate conj between? nil? =~ !~ hash class singleton_class clone dup taint tainted? untaint untrust untrusted? trust freeze frozen? methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for equal? ! != instance_eval instance_exec __send__ __id__ 3.14 (Float) to_s inspect coerce -@ + - * / quo fdiv % modulo divmod ** == === <=> > >= < <= eql? hash to_f abs magnitude zero? to_i to_int floor ceil round truncate nan? infinite? finite? numerator denominator to_r rationalize arg angle phase singleton_method_added i +@ div remainder real? integer? nonzero? step to_c real imaginary imag abs2 rectangular rect polar conjugate conj between? nil? =~ !~ class singleton_class clone dup taint tainted? untaint untrust untrusted? trust freeze frozen? methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for equal? ! != instance_eval instance_exec __send__ __id__ Pi (String) <=> == === eql? hash casecmp + * % [] []= insert length size bytesize empty? =~ match succ succ! next next! upto index rindex replace clear chr getbyte setbyte byteslice scrub scrub! freeze to_i to_f to_s to_str inspect dump upcase downcase capitalize swapcase upcase! downcase! capitalize! swapcase! hex oct split lines bytes chars codepoints reverse reverse! concat << prepend crypt intern to_sym ord include? start_with? end_with? scan ljust rjust center sub gsub chop chomp strip lstrip rstrip sub! gsub! chop! chomp! strip! lstrip! rstrip! tr tr_s delete squeeze count tr! tr_s! delete! squeeze! each_line each_byte each_char each_codepoint sum slice slice! partition rpartition encoding force_encoding b valid_encoding? ascii_only? unpack encode encode! to_r to_c > >= < <= between? nil? !~ class singleton_class clone dup taint tainted? untaint untrust untrusted? trust frozen? methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for equal? ! != instance_eval instance_exec __send__ __id__ π (String) <=> == === eql? hash casecmp + * % [] []= insert length size bytesize empty? =~ match succ succ! next next! upto index rindex replace clear chr getbyte setbyte byteslice scrub scrub! freeze to_i to_f to_s to_str inspect dump upcase downcase capitalize swapcase upcase! downcase! capitalize! swapcase! hex oct split lines bytes chars codepoints reverse reverse! concat << prepend crypt intern to_sym ord include? start_with? end_with? scan ljust rjust center sub gsub chop chomp strip lstrip rstrip sub! gsub! chop! chomp! strip! lstrip! rstrip! tr tr_s delete squeeze count tr! tr_s! delete! squeeze! each_line each_byte each_char each_codepoint sum slice slice! partition rpartition encoding force_encoding b valid_encoding? ascii_only? unpack encode encode! to_r to_c > >= < <= between? nil? !~ class singleton_class clone dup taint tainted? untaint untrust untrusted? trust frozen? methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for equal? ! != instance_eval instance_exec __send__ __id__ false (FalseClass) to_s inspect & | ^ nil? === =~ !~ eql? hash <=> class singleton_class clone dup taint tainted? untaint untrust untrusted? trust freeze frozen? methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for == equal? ! != instance_eval instance_exec __send__ __id__ true (TrueClass) to_s inspect & | ^ nil? === =~ !~ eql? hash <=> class singleton_class clone dup taint tainted? untaint untrust untrusted? trust freeze frozen? methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for == equal? ! != instance_eval instance_exec __send__ __id__ => [4, 3.14, "Pi", "π", false, true] object-all-things-2.rb(main):008:0>