VERY simple question about "?"

I absolutely love Ruby, but…I’ve always found the subject of Ruby
operators to be a small nightmare. First, it’s hard to find a complete
table - the best I’ve found says gleefully at its bottom “and there are
even more”. Wonderful. So many tools, so little time…

Then there’s the matter of some symbols being operators, others being
methods, and some (my impression only) both, and yet others being a
number of things, depending upon context. When someone says that Ruby is
harder than Python, I suppose this might be what they mean. makes sense
to me.

So, just today I learn that this is possible:

irb(main):001:0> ?.
=> 46
irb(main):002:0> ?a
=> 97
irb(main):003:0> 97.chr
=> “a”
irb(main):004:0>

So…what is this “?” thing? I’ve looked in four references, and Googled
until I’m dizzy, and find no answer. Operator? Method? (Stupid
distinction???)

I know I’ll certainly be using this, but it’d be nice to know what I’m
doing.

All comments welcome.

t.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

Le 4 janvier 2009 à 12:58, Tom C. a écrit :

So…what is this “?” thing? I’ve looked in four references, and Googled
until I’m dizzy, and find no answer. Operator? Method? (Stupid
distinction???)

It’s simply a language construct, like the ’ that delimitates a string
or the : that starts a symbol.

If you have the pickaxe book, it’s documented in the “Integer and
Floating-Point Numbers” section (page 304 and 305 of my PDF edition).

Fred

On Sun, Jan 4, 2009 at 3:34 PM, F. Senault [email protected] wrote:

If you have the pickaxe book, it’s documented in the “Integer and
Floating-Point Numbers” section (page 304 and 305 of my PDF edition).

And if you don’t have the book, you can read that section1 in the
online
version.

Regards,
Yaser

Yaser S. wrote:

Regards,
Yaser

Thanks, guys.

I guess what confused me is that I bring to Ruby the notion that if a
symbol causes something to happen, as “?” clearly does in my example (it
produces the integer code for a character), its’ an operator or method.
I’m not unfamiliar with linguistics. I don’t see the equivalence between
a string delimiter, or a character that signals the beginning of a
symbol, and a symbol that is actually productive of something. Makes no
sense to me at all, in fact. Maybe I’m failing to grasp some
transformative concept which changes how things work in the Ruby world.

Seeing operators as methods makes some real sense, on the other hand.
“=” produces something out of what it’s given. It doesn’t just change
meaning, which is all that happens with quotes or “:”. That’s the
distinction I’m seeing, and it seems valid.

I’ll keep thinking about it.

Quite apart from this is the strange matter of how difficult it is to
find a simple, complete table of Ruby operators. I’ve basically given up
on that.

Thanks for the Pickaxe reference - I found it on PDF p. 332 of my PDF
version of the 2nd ed. I’d never seen that page.

t.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

On 04.01.2009 14:48, Tom C. wrote:

I guess what confused me is that I bring to Ruby the notion that if a
symbol causes something to happen, as “?” clearly does in my example (it
produces the integer code for a character),

In this case nothing “happens” (see below). It is just another
syntactical way to express an integer constant.

distinction I’m seeing, and it seems valid.
I am not sure what you mean by “change meaning”. Can you elaborate?

Btw, note that there are two types of “=”:

  1. variable assignment as in “a = 123”,

  2. method call that mimics variable assignment as in “a.foo = 456”.

Both evaluate always to the right hand side - but this is about the only
commonality. Semantics of type 1 is fixed while you are free to
implement type 2 in any way you like, e.g.

irb(main):005:0> a = Object.new
=> #Object:0x7ff79980
irb(main):006:0> def a.foo=(x) puts “bah!” end
=> nil
irb(main):007:0> a.foo = 456
bah!
=> 456
irb(main):008:0>

I’ll keep thinking about it.

Basically “?a” is just another textual representation for the integer 97
which happens to be the ASCII code of character “a”. It differs from
string delimiters because the expression “foo” is actually a String
constructor - it will create a new String object whenever it is
executed:

irb(main):003:0> 3.times { x = “foo”; puts x, x.object_id }
foo
1073491940
foo
1073492040
foo
1073491880
=> 3
irb(main):004:0>

Quite apart from this is the strange matter of how difficult it is to
find a simple, complete table of Ruby operators. I’ve basically given up
on that.

You can find it in the Pickaxe - a good book to have anyway.

Thanks for the Pickaxe reference - I found it on PDF p. 332 of my PDF
version of the 2nd ed. I’d never seen that page.

As far as I know there is no legal electronic version of the second
edition so you better double check whether you are allowed to use this.
You could as well buy the book to somewhat compensate for this.

Kind regards

robert

On Sun, Jan 4, 2009 at 9:48 AM, Robert K.
[email protected] wrote:

see the equivalence between a string delimiter, or a character that signals

irb(main):005:0> a = Object.new
Basically “?a” is just another textual representation for the integer 97
1073491880

As far as I know there is no legal electronic version of the second edition
so you better double check whether you are allowed to use this. You could
as well buy the book to somewhat compensate for this.

There definitely is an option to select a PDF version for purchase.

2009/1/4 Michael G. [email protected]:

On Sun, Jan 4, 2009 at 9:48 AM, Robert K.
[email protected] wrote:

As far as I know there is no legal electronic version of the second edition
so you better double check whether you are allowed to use this. You could
as well buy the book to somewhat compensate for this.

Pragmatic Bookshelf: By Developers, For Developers

There definitely is an option to select a PDF version for purchase.

Thanks for the education! I wasn’t aware of this. There was
definitively an illegal PDF version offered (even here) in the past.

Kind regards

robert

Robert K. wrote:

robert

I wouldn’t engage with a illegitimate copy - isn’t playing fair at all.
I completely believe in “intellectual property”. My copy certainly WAS
purchased from the Pragmatic Programmers website. Marvelous book, of
course, but it does not, to my best knowledge, contain a complete list
of operators. I’ve done everything I can think of to find it. I
seriously doubt that it’s there. The precedence table on 324 is about
precedence, and not a primary presentation of operators and their
function.

More incredibly, “operator” is not even in the index as a primary index
term - in the sense that I’m accustomed to the use of the word in
programming languages.

Here’s the entry that IS there:

Operator
as method call 82, 335
precedence 324

To me, this is simply strange. Dave T., whose contributions to the
Ruby community are inestimably valuable, may see this thread, in which
case I hope he comments. I’ve been completely bewildered about this for
a long time.

t.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

On Sun, Jan 4, 2009 at 5:06 PM, Tom C. [email protected] wrote:

There definitely is an option to select a PDF version for purchase.

languages.
time.
Not sure if the following list is comprehensive, but useful
nonetheless…

…you’ll find the first use of ? under Reserved words.

Todd

On Sun, Jan 4, 2009 at 5:36 PM, Todd B. [email protected] wrote:

  • in the sense that I’m accustomed to the use of the word in programming
    hope he comments. I’ve been completely bewildered about this for a long
    time.

Not sure if the following list is comprehensive, but useful nonetheless…

Ruby | zenspider.com | by ryan davis

…you’ll find the first use of ? under Reserved words.

I meant beneath Reserved words. It’s actually classified under
Types/Numbers.

Todd

Todd B. wrote:

[email protected] wrote:

robert

To me, this is simply strange. Dave T., whose contributions to the Ruby

I meant beneath Reserved words. It’s actually classified under Types/Numbers.

Todd

Definitely a useful page, about which I’ve known for some time.
Outstanding for its brevity. Limited at times, because if you don’t
already know what he’s talking about, you’re not much enlightened by the
page content at all. Two examples:

  • “Here docs” (right above “Symbols”). I know what this is, and I STILL
    cannot quickly make sense of the notes on the pages about this
    functionality.
  • Operators - has the same problem as Thomas’ book: precedence is shown,
    but basic operator function appears to be assumed to be known. I’m
    sorry, but I wasn’t born with that knowledge. Look at this line: <=> ==
    === != =~ !~

There’s some very strange stuff there. I’m only certain about the
function of ONE of these, and I’ve been using Ruby for probably over a
year an a half (remember - I’m an intermittent weekend programmer, of
necessity).

All that said, I find Ryan D.'s work simply amazing, and I’m very
grateful for his presence in the world. His “Ruby QuickRef” at
Ruby | zenspider.com | by ryan davis is likely
supposed to be more cheat sheet than brief tutorial, to be fair.

The best presentation of Ruby operators I’ve yet found (looking mostly
on the web) is at Ruby - Operators.
Also good are those at
http://www.techotopia.com/index.php/Ruby_Operators and
Computer & Software Services & Scientific Services Trademarks - Alter.
So, this stuff can be found, but you have to go looking for it.

t.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

On Jan 4, 2009, at 5:06 PM, Tom C. wrote:

I wouldn’t engage with a illegitimate copy - isn’t playing fair at
all. I completely believe in “intellectual property”. My copy
certainly WAS purchased from the Pragmatic Programmers website.

And we appreciate that :slight_smile:

Marvelous book, of course, but it does not, to my best knowledge,
contain a complete list of operators. I’ve done everything I can
think of to find it. I seriously doubt that it’s there. The
precedence table on 324 is about precedence, and not a primary
presentation of operators and their function.

Which methods/operators are missing from the precedence table? I’ll
add them.

?, tho’ is not an operator, any more than the quote is in “cat”
or the slash in /cat/. In all three cases they’re simply syntax for
literals.

Here’s the entry that IS there:

Operator
as method call 82, 335
precedence 324

To me, this is simply strange. Dave T., whose contributions to
the Ruby community are inestimably valuable, may see this thread, in
which case I hope he comments. I’ve been completely bewildered about
this for a long time.

Let me know what to add, and I’ll definitely consider adding it. But
be aware that I don’t really consider the concept of “an operator” to
be particular primary in the description of the language, because in
Ruby there’ll always be debate about just what is an operator. The
precedence table is my best take on it—I derived it from the parser,
and I believe it contains every operator-like thing I could find in
there. But, as I said, I’d love to hear suggestions, as the third
edition is nearing completion, and I’m always open for ideas to make
it better.

Cheers

Dave

Dave T. wrote:

contain a complete list of operators. I’ve done everything I can
think of to find it. I seriously doubt that it’s there. The
precedence table on 324 is about precedence, and not a primary
presentation of operators and their function.

Which methods/operators are missing from the precedence table? I’ll
add them.
Oh, man…now I’ve going to have to get rigorous in my consideration of
the topic, aren’t I? Heh heh. Probably about time, too. So…I’ll go on
a search and recover mission, if only for my own edification. If I find
anything, I’ll report back. Probably will anyway.

But to me the basic problem with the p. 324 table, as I suggested, is
that its subject is about precedence - a completely legitimate subject -
and is NOT primarily a presentation of operators with an explication of
what they DO. THAT’s what I looked for practically the first time I
encountered the book, and have been looking for ever since.

As I just said in a response to Todd’s post, The best presentation of
Ruby operators I’ve yet found (looking mostly on the web) is at
Ruby - Operators. THIS is the sort
of presentation I expect in ANY language book. It seems fully as basic
as a definition of what a variable is and how one works, along with all
the other basic building blocks of the language. Languages are build up
from primitives - analogous to the premises in a logical argument. If
the premises are unclear, the argument cannot go forward, and that’s
been exactly my experience with Ruby. I encounter some strange operator

  • like the “?” encounter I had last night, and I want to go read about
    this thing. After well over 30 minutes search through quite a range of
    material, I had found next to nothing. That’s nuts, to me.

?, tho’ is not an operator, any more than the quote is in “cat”
or the slash in /cat/. In all three cases they’re simply syntax for
literals.
I’m still struggling here. When syntax is productive of something, I see
an operation occurring - active functionality. I’m perfectly content to
see operators as methods. Syntactically there’s no problem that I can
detect in that construct. But to call “?” a literal…well, I must
go study up a bit on this. To me, “abcdef” is a literal. ‘\n’ is too.
“\n” is a literal if you allow meaning to be contexturalized, which
should be no problem. As input to various processes, ‘\n’ and “\n” have
different outcomes, but by themselves produce nothing. “?”
produces something. Irb makes this clear (to me):

irb(main):006:0> puts ‘\n’
\n
=> nil
irb(main):007:0> puts “\n”

=> nil
irb(main):008:0> puts ?\n
10
=> nil
irb(main):009:0>

If in “-1”, we consider the “-” to be an operator, then I see an exact
parallel to the function of “?a”.

It’s not the same as what quote marks do - THEY provide context, and
change meaning. Operators PRODUCE something. They “operate”. It seems
very simple. If I’m making a fundamental error, I’d be very grateful to
have it point out to me. I highly value arriving at a place of clear
understanding, when it’s possible.

this for a long time.

Let me know what to add, and I’ll definitely consider adding it. But
be aware that I don’t really consider the concept of “an operator” to
be particular primary in the description of the language, because in
Ruby there’ll always be debate about just what is an operator. The
precedence table is my best take on it—I derived it from the parser,
and I believe it contains every operator-like thing I could find in
there. But, as I said, I’d love to hear suggestions, as the third
edition is nearing completion, and I’m always open for ideas to make
it better.
Dave, the function descriptions in this table are too minimal, I think.
Not enough for a beginner - not for this one, anyway, and Ruby is at
least the fifth language I’ve dug around in. In all the others (Fortran,
APL, Pascal/Delphi, Basic, Python, a tabular presentation of the
operators the languages recognizes was shown to me EARLY, and I always
found it highly informative, since it told me what I could DO with
primitive units of data. Seems like an excellent starting point for more
complex topics.

Your comment about the operator concept is very interesting. I think
that it would be really, truly helpful for you to lay out Ruby more from
the ground up - shown me clearly it fundamental components, beginning
with the ‘primitives’ - reserved words are primitives, and so are
variables, etc. Operators, too, I’d say. From these things we build
other things, like data containers - meta-primitives, if you will.

I have always been greatly bewildered that in your book (I’m looking at
2nd edition PDF again), we’re into arrays and hashes on p. 14 and I have
to encounter anything substantive about operators - those things that
glue together variables and constants so that we can form expressions.

Maybe I just bring the wrong mindset to Ruby. I’m willing to be told
that, if I’m shown a better one. However, I’d bet that a great many of
us did study grammar in school (remember “parts of speech”?), and some
of us have studied linguistics, and many of us have at least dabbled in
other languages. There are conventions about how we talk about human
communication, in general, computer languages included. When I come to a
presentation of a new language, the first thing I look for is the
familiar. I want some secure ground I can readily claim (“oh, I know
what THAT is!”), so that I can move from that out into the wilderness of
new territory.

For me that secure ground in anything of linguistic nature will always
be the “meme” concept - in formal linguistics this would be an analysis
of phonemes (aural primitives - irreducible units of sound) and
graphemes (irreducible units of sound representation), etc. None of
these concepts are perfect, but they ARE plainly very useful. The basic
model is very familiar: premises (or data, if you will) + logic (legal
operations) = argument (or assertion or expression). This model is a
part of our cultural memory, as it were.

I want someone to show me the pieces of something, and how they go
together. I don’t want complexity until I grasp the little things, at
least at the conceptual, if not the operational/functional, level. I
love the highly informative narratives you lay out in your book, about
all manner of topics. But I’m bewildered that in Ch. 2, the first real
content about the language per se, we’re right away talking about OO
programming. I don’t yet have the pieces of the language, at this point.
How can I think about how OO programming is done in Ruby. It’s as if I’m
being asked to walk on air. Obviously, this is just one man’s reaction,
and I full well know you’ll see it that way. No problem.

If ANY of this is of any use to you in any way, it’s worth the time it
took for me to lay it out. I don’t expect a response. I’m only hoping
that maybe some of my perspective might be useful to you. If you get a
chance to read it at all, I’m content simply with that.

3rd edition coming out soon, eh? I have to say that one of the great
joys of being in the Ruby community is that the future looks so
interesting - and this is one piece of it we can all look forward to.
I’m sure you’ll have my money soon enough, and it’ll be a bargain! Best
of luck with your work on this project, and my thanks as well.

Thanks…

Tom

Cheers

Dave

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

Robert K. wrote:

that signals the beginning of a symbol, and a symbol that is actually
productive of something. Makes no sense to me at all, in fact. Maybe
I’m failing to grasp some transformative concept which changes how
things work in the Ruby world.

Seeing operators as methods makes some real sense, on the other hand.
“=” produces something out of what it’s given. It doesn’t just change
meaning, which is all that happens with quotes or “:”. That’s the
distinction I’m seeing, and it seems valid.

I am not sure what you mean by “change meaning”. Can you elaborate?
Meaning, in linguistics as I understand it, is inherent, contextural, or
both. “a” is inherently a character in the basic Roman alphabet used by
many European languages. As a representation of a sound, its meaning
changes depending upon context. Consider “pat” and “pate”. Adding the
suffix “e” to the consonant+vowel+consonant construction changes the
sound of the “a”. In Ruby, customer_count (a variable) and
“customer_count” (a string) don’t mean the same thing, because the
latter has a prefix and suffix of the " symbol. Contextural meaning
production is occurring. Ditto for the use of “:” in symbols. The “”"
and the “:” are context indicators, but produce nothing. Not so for “+”
in “a+b” or, I think “?a”. Something is emitted, here. That goes well
beyond mere contextual meaning production, which is also occurring, to
be sure. I hope I’m being clear enough here.

irb(main):005:0> a = Object.new
=> #Object:0x7ff79980
irb(main):006:0> def a.foo=(x) puts “bah!” end
=> nil
irb(main):007:0> a.foo = 456
bah!
=> 456
irb(main):008:0>
Thanks! That’s fun, and interesting.

I’ll keep thinking about it.

Basically “?a” is just another textual representation for the integer
97 which happens to be the ASCII code of character “a”. It differs
from string delimiters because the expression “foo” is actually a
String constructor - it will create a new String object whenever it is
executed:

irb(main):003:0> 3.times { x = “foo”; puts x, x.object_id }
A “textural representation” that PRODUCES something? Doesn’t make sense
to me. Representations simply represent. They “stand for” something
else, and do no more.

Now, I can define method X, and then say that X “stands for” the method
specification. That’s true, from the compiler’s point of view, among
other things. But to say no more is misleading. “X” can be called, at
which point it ACTS. “Tom” - my name can also be called, but when one
does so IT doesn’t spring into action at all. I might, but IT cannot.

There is, I therefore assert, a fundamental difference here, and I think
you’re seeing that two different things have the same feature and
concluding from that that they are the same sort of thing. That argument
is obviously flawed. "It’s incomplete, as my “Tom” demonstrations shows.
You say “Basically “?a” is just another textual representation for…” -
I’d agree, except for that “just”. That single word makes the statement
incorrect, to my mind, and also reveals the problem I’m addressing.

foo
1073491940
foo
1073492040
foo
1073491880
=> 3
irb(main):004:0>

[…]

Thanks for your thoughts. I appreciate your sharing them.

t.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

On Jan 4, 2009, at 8:14 PM, Tom C. wrote:

If in “-1”, we consider the “-” to be an operator, then I see an
exact parallel to the function of “?a”.

It’s not the same as what quote marks do - THEY provide context, and
change meaning. Operators PRODUCE something. They “operate”. It
seems very simple. If I’m making a fundamental error, I’d be very
grateful to have it point out to me. I highly value arriving at a
place of clear understanding, when it’s possible

I think you’re over thinking it. For example, in

0x10

which is 16 in decimal, is the ‘0x’ part an operator? If you say no
(which I hope you do) then why would you say that ? is an operator in ?
a (which is 97). They are simply characters that are used by the
lexical analysis phase to help interpret what follows. No executable
code is generated: there’s no operation.

Similarly, in your example of -1, the - sign is NOT an operator. It
simply means that when parsing the constant, a negative value is
required. Again, so executable code is generated. That’s the
difference between

a = -1      # -1 is a constant, no operator
b = -a      # the unary minus operator (-@) is invoked on the

object referenced by a

Cheers

Dave

Dave T. wrote:

processes, ‘\n’ and “\n” have different outcomes, but by themselves
10
clear understanding, when it’s possible

Dave

Thanks, Dave. This helps. You have a genuine knack for simple clear
statement and example. Thanks for the dialog!

t.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

Tom C. wrote:

  • Operators - has the same problem as Thomas’ book: precedence is shown,
    but basic operator function appears to be assumed to be known. I’m
    sorry, but I wasn’t born with that knowledge. Look at this line: <=> ==
    === != =~ !~

There aren’t really any operators in Ruby. Ruby simply maps all these to
method calls (*), so to find out what the operator means you have to
look at the class documentation for that method.

e.g.
str1 = “foo”
str2 = “bar”
p str1 <=> str2

Here you need to look at the documentation for String#<=> to see what it
means. Yes, “<=>” is a legitimate method name :slight_smile: You can also call it
like this:

str1.<=>(str2)

The only real purpose of the operator precedence table is to show how
expressions containing multiple operators are resolved. e.g.

1 + 2 * 3

same as:

1 + (2 * 3)

same as:

1.+(2.*(3))

Note that even the methods ‘+’ and ‘*’ do not necessarily have anything
to do with addition or multiplication. It’s entirely dependent on the
target object how it implements these methods. For example:

“123” * 3 # => “123123123”

HTH,

Brian.

(*) The exceptions in ruby 1.8 are != and !~, which invoke the methods
== and =~ but then negate the result

Tom C. wrote:

<=> == === != =~ !~

There’s some very strange stuff there. I’m only certain about the
function of ONE of these

As has already been mentionen, they are methods and do whatever they’re
defined to do. That being said here’s what their intended function is:
<=> should be defined by any class that includes the Comaparable module.
It
should return -1,0 or 1 depending on whether the receiver (the lhs) is
less
than, equal to or greater than the argument (the rhs).

== should return true if (and only if) the lhs is equal to the rhs
(where the
definition of equality depends on the class). Object#== is defined to
return
true if two objects are actually the same object (i.e. both the receiver
and
the argument are actually references to the same location in memory).

=== defines when an object “matches” another object in a
case-when-statement
(or the grep method). For example in the following code, the puts will
be
executed if y === x is true:
case x
when y
puts “tada”
end
Object#=== is defined to return the same as ==, Regexp#=== is defined to
return true if the regexp matches a string and Range#=== is defined to
return true if a given object is inside the range.

!= is simply the negation of ==, so x != y is equivalent to !(x == y)

Regexp#=~, which takes a string as an argument, and String#=~, which
takes a
regex as an argument, return the index where the regex matches the
string or
nil if the regex does not match the string.

All of those are documented in the API docs btw.

HTH,
Sebastian

Brian C. wrote:

look at the class documentation for that method.
str1.<=>(str2)

1.+(2.*(3))

(*) The exceptions in ruby 1.8 are != and !~, which invoke the methods
== and =~ but then negate the result

Ah…This is actually very helpful. I think we have a language problem,
though. If there are no operators in Ruby, we should call all those
methods with non-alphabetical names something besides “operators”. I
know…we get USED to nonsense. Every try to learn to spell English? I
still don’t do it well. But we live with it. Here, I think we need to
change not only the computer language (experts appear to be evolving it
quite nicely, and I’m happy just to watch), but the human language we
use to talk about it. I guess this particularly matters to me because I
write a lot - daily. I virtually live at a keyboard. Verbal coherence
matters a lot to me, even if I can’t always achieve it.

OK, let’s assume we have the language problem solved (ha! - not likely
to happen). Nann-methods == “non-alphabetically-named methods”. The core
problem still remains - what the blazes does that THING
do/mean/produce…??? Here’s were your post is helpful to me. I will
follow your suggestion. I feel better already, because for the first
time in a long time [a] I understand my confusion, AND [2] what to do
about it. A whole new world.

Dave…if you’re still listening…it’d be lovely if some clarification
along the lines of this post made it into your 3rd edition - that’s what
I find myself thinking, anyway.

Thanks to all…for hanging with me on this one.

Thanks.

T.

Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< [email protected] >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

On 05.01.2009 10:58, Brian C. wrote:

There aren’t really any operators in Ruby. Ruby simply maps all these to
method calls (*), so to find out what the operator means you have to
look at the class documentation for that method.

The only real purpose of the operator precedence table is to show how
expressions containing multiple operators are resolved. e.g.

Brian, you are contradicting yourself: first you deny the presence of
operators in Ruby and then you talk about them nevertheless. :slight_smile:

Fact is, there are operators in Ruby - and they do have a precedence.
(I am not sure why you put an “only” into the sentence above -
operator precedence is what a precedence table is about.)

Fact is also, that their semantics are defined via methods. Note also
that for understanding the semantics of most binary operators the method
#coerce plays a crucial role (=> double dispatch).

Kind regards

robert