Misc #15744

Improvement needed to documentation of 'Literals'

Added by CaryInVictoria (Cary Swoveland) over 1 year ago. Updated about 1 year ago.



Documentation of "Literals" for v2.6.0 is given here: (I don't think it has been changed for some time.) It gives examples of literals but does not provide a definition. It is comparable to defining an array by giving a few examples. I believe a definition is needed.

I would like to suggest a definition, but I confess I don't know what a Ruby literal is. A definition is attempted at this Wiki for computer programming generally:

I suspect a Ruby literal is an object whose value is in some sense "known" at compile-time. For example, I would think 1, 1.0 and { a: [1, 'cat', ['dog', ['pig', ..10]]] } are literals but { v=>1, 2=>3 } in h = { v=>1, 2=>3 }, v being a variable, is not. Or is it? If the previous line of code had been v=3, Ruby could, at compile-time, infer that the line could be replaced with h = {3=>1, 2=>3}, in which case it would be "known". This example is meant to illustrate why I earlier said "in some sense".

Also available in: Atom PDF