Ruby display each array item's index
my_vitamins.each_with_index do |vitamin, index|
puts "#{index} cheers for #{vitamin}!"
end
=> 0 cheers for b-12!
=> 1 cheers for c!
=> 2 cheers for riboflavin!
1 comment
Typo code formatting
If you want to format code in your Typo blog you may do so by using the typo:code block and setting the following options:
- lang. Sets the programming language. Currently supported languages are ruby, C, Delphi, HTML, RHTML, Nitro-XHTML, CSS, Diff, Java, * Javascript and yaml. Other languages will format correctly but will not have syntax highlighting.
- linenumber. Turns on line numbering. Use linenumber=“true” to enable.
- title. Adds a title block to the top of the code block.
More information at: