Skip to content

About overriding Float#to_s #5

@mhama

Description

@mhama

In my understanding, overriding Float#to_s (https://github.com/cjbissonnette/RubyScad/blob/master/lib/rubyscad/RubyScad.rb#L12) affects every code that require RubyScad gem, and may break some behaviors outside this gem. So it'll be better to get rid of overriding Float#to_s, and use other way like using normal value-formatting method, or using special inherited Float class.

I found this behavior when using CrystalScad(https://github.com/Joaz/CrystalScad), which is using this gem. It is strange that the result of "#{some_float_value}" changes if I require 'crystalscad'.

$ ruby -e "puts 3.0"
3.0
$ gem install crystalscad # if needed
$ ruby -rcrystalscad -e "puts 3.0"
3.000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions