Ruby constants
Posted: Tue Nov 22, 2016 2:11 pm
Hi,
Stupid question, but still... Any hint on how can I use mathematical constants in ruby?
I want o use 'exp' (natural exponent = 2.71...) or Pi (=3.1415...) in Ruby and looking for a short way to type it in.
I was trying E, math.E, etc but couldn't find a way.
Google didn't help much either...
The only solution I found so far is to define a constant at start of Ruby code, example:
@E=Math.exp(1)
But I guess there is a better way ??
Thanks
Stupid question, but still... Any hint on how can I use mathematical constants in ruby?
I want o use 'exp' (natural exponent = 2.71...) or Pi (=3.1415...) in Ruby and looking for a short way to type it in.
I was trying E, math.E, etc but couldn't find a way.
Google didn't help much either...
The only solution I found so far is to define a constant at start of Ruby code, example:
@E=Math.exp(1)
But I guess there is a better way ??
Thanks