Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does <tt> stand for in Ruby comments?

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?

like image 366
Vitaliy Yanchuk Avatar asked Dec 20 '12 12:12

Vitaliy Yanchuk


People also ask

What are comments in Ruby?

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.

How do you comment out code in Ruby?

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.

What is magic comment in Ruby?

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.


1 Answers

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

like image 199
Xentatt Avatar answered Oct 17 '22 15:10

Xentatt