As I retrieve data from a database table an array is populated. Some of the fields are defined as decimal & money fields and within the array they are represented as BigDecimal.
I use these array values to populate a CSV file, but the problem is that all BigDecimal values are by default represented in Scientific format (which is the default behaviour of the BigDecimal to_s method). I can show the values by using to_s(‘F’), but how can I override the default?
This is built on @Farrel’s answer, but without polluting the method namespace with a useless
old_xyzmethod. Also, why not use default arguments directly?In Ruby 1.8, this gets slightly uglier:
Or, if you don’t like the warning you get with the above code: