How To Extend Float Class in Ruby
Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.
As we are going to extend, create an extensions folder inside lib and create a float.rb inside this folder.
Now we need to initialize this module when application starts so that we can access this method in entire application. Create a file load_extensions.rb in initializers
Now restart your server; that’s it. Now you can apply this
with_precision() on float object anywhere in Application.
Consulting is free – let us help you grow!
Choose Your Language
- Digital Marketing
- IT Consulting
- Project Management