Math functions and SU7
-
I just noticed while testing some of my SU6 plugins that there is a problem with the inbuilt Ruby Math functions. If I type the following into the Ruby console I get an error:
tan(20)
Error: #<NoMethodError: (eval):56: undefined method `tan' for main:Object>
(eval):56
Math::tan(20)
2.23716094422474tan(20) works with SU6
Can someone confirn this
-
Hi Bill,
This isn't unexpected behavior. tan is a method of the Math module, and you need to prefix it with the module name in order to call it. If you type in the Ruby Console:
include Maththen simply writing tan(20) will work. To ensure you are using Math::tan, and not someone else's 'tan' method, you probably want to always write it as 'Math::tan'
Here is a chapter which discusses modules as namespaces:
http://www.rubycentral.com/pickaxe/tut_modules.html
It could be that there is a plugin in your version 6 folder that uses 'include Math' and so 'tan' is available in your version 6 Ruby Console.
-
Without "include Math" statement (directly from Ruby's console or from any autoloaded plugin), it does not work here. With "Math included", it works fine.
Marcio
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement