Ruby String Formatting
Want some zero-padding with that burger? Read this tutorial to learn how to do that and more. http://www.blackbytes.info/2012/01/ruby-string-formatting/
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Want some zero-padding with that burger? Read this tutorial to learn how to do that and more. http://www.blackbytes.info/2012/01/ruby-string-formatting/
Comments
This is one of my first Ruby articles that I just updated for your enjoyment. Hopefully you find it interesting :)
http://rubylearning.com/satishtalim/mutable_and_immutable_objects.html
In ruby 2.3 they are changed.
Kanna, this is not true, in Ruby 2.3 the strings are not immutable by default. This is going to happen in Ruby 3. However, it is possible to make strings immutable in Ruby 2.3 if you use the frozen_string_literal: true pragma or start Ruby with the –enable-frozen-string-literal option. Then you could do strings formatting with
String.new "Some %0.2f" % 78.938
and the output will beSome 78.94
.Post a comment