Going over source code written in Ruby, like Rails, I often see that small code is wrapped with tt
tag, like in rails/activesupport/core_ext/array/access.rb
# Equal to <tt>self[2]</tt>.
#
# %w( a b c d e).third # => "c"
def third
self[2]
end
What is the convention behind this, when and why it was decided to use this notation?
Ruby comments are non executable lines in a program. These lines are ignored by the interpreter hence they don't execute while execution of a program. They are written by a programmer to explain their code so that others who look at the code will understand it in a better way.
The Ruby single-line comment begins with the # character and ends at the end of the line. Any characters from the # character to the end of the line are completely ignored by the Ruby interpreter. The # character doesn't necessarily have to occur at the beginning of the line; it can occur anywhere.
A magic comment changes the behavior of the Ruby interpreter in some way. For example: The frozen_string_literals comment will make your strings frozen by default. It looks like this: # frozen_string_literal: true. Another magic comment allows you to change the file's encoding.
Yep, my mistake, sorry
This is a part of special RDoc system.
Non-verbatim text can be marked up:
italic: word or <em>text</em>
bold: word or <b>text</b>
typewriter: word or <tt>text</tt>
Read more about it here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With