Skip to content

Instantly share code, notes, and snippets.

@damianesteban
Created December 6, 2013 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damianesteban/7834093 to your computer and use it in GitHub Desktop.
Save damianesteban/7834093 to your computer and use it in GitHub Desktop.
# Week One Exercise 2
# Read the sprintf documentation and the % documentation in the
# String class and figure out the output being printed by of this Ruby code.
puts "%05d" % 123
# The output is 00123
# Similar to Python, % can be used as a formatter.
# I looked up the usage of 'd' as an argument formatter in the
# ruby docs, 'd' converts the argument as a decimal number.
# There was no decimal point in our code, so Ruby "tacks on" two zeros
# proceeding 123 (I think)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment