It's not sending a message - that would defeat the purpose. It's constructing a frozen string, reusing an existing one when possible.
Prior to 2.1:
def foo
"bar".freeze
end
does these things every time `foo` is called:1. copies the characters 'b', 'a', and 'r' into a mutable string
2. sends the message `freeze` to the new string, which...
3. marks the string as frozen.
In 2.1 `"bar".freeze` is equivalent to `"bar"f`, which will not make a copy every time `foo` is called. See https://bugs.ruby-lang.org/issues/8579 for more discussion.
Re:What's New in Ruby 2.1 [pdf]
by jamesbritt on Wednesday November 27, 2013 @07:32PM
(#6812290)
I see. Thank you.
Re:What's New in Ruby 2.1 [pdf]
by aaronblohowiak on Wednesday November 27, 2013 @02:44PM
(#6810588)
it is not sending a message any more than 0b100 is sending a message. this is syntax for a type.
Worse, it seems to break the model of "interact with objects by sending messages", where you send a message using
Is "foo"f _not_ sending a message? If so, then what is it doing? If yes, then why new syntax?