RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

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!

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/

Comments

This is one of my first Ruby articles that I just updated for your enjoyment. Hopefully you find it interesting :)

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 be Some 78.94.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in