Ruby/Development/Math.constants
Материал из Wiki.crossplatform.ru
(Различия между версиями)
Версия 17:10, 26 мая 2010
Euler and PI
print Math::E # => 2.71828182845905 print Math::PI # => 3.14159265358979
Math.const_set and get
Math.const_set(:EPI, Math::E*Math::PI) Math.const_get(:EPI) # => 8.53973422267357 Math.const_defined? :EPI # => true
To find out what constants Math (or any other module or class) has defined, use reflection by invoking the constants method
puts Math.constants