pygeek pygeek - 15 days ago 5
Ruby Question

Why are references to methods in Ruby formatted "`method'" instead of "`method`"?

I've been writing more Ruby lately and curious about error formatting choice in the language.

When Ruby references another method it formats it with a single back tick followed by a quote.

Other languages that I'm familiar with typically reference a method by using back ticks, quotes, or nothing, but never both.

I was wondering if anyone knew the rationale for this, if any.

Answer

Quoting strings as

`foo'

is based on roff usage, where a backquote represents an opening quotation mark and a single quote represents a closing quotation mark. man pages are formatted using roff, but the ASCII text rendering retains the original markup in place of proper "typographic" quotes or using the one or the other for both quotes. Its use in Ruby, then, has no real technical meaning, other than (I suspect) making a stylistic choice that matches man page rendering.