There is no print in any of this. Second, asking a hash for a key or a value both return a string. String plus string plus string, should result in a string, as per documentation.
Module: Kernel (Ruby 2.3.0) which leads to Class: IO (Ruby 2.3.0) which says: "Writes the given objects to ios as with IO#print."
Asking a hash for a key or a value both return whatever object is used in the hash's key or value. If those are Strings, then it returns Strings.
A join on two symbols and an object which, in this case, was decidedly a string. The result is a hash because the string contains “ => “?
~~~
hsh = { 0 => 3.14, :foo => Object.new }
hsh[0].class #=> Float
hsh.keys[1].class #=> Symbol
# and finally
hsh.each{nil} == hsh #=> true
~~~
Yes, joining two Strings with a String results in a String... which is then printed using `puts`. It's not returned in any way. I know I've said this already, and I assume you've understood even though you haven't acknowledged it (which is why I've repeated it again here.) I just want to make sure the original issue is resolved and clear.
The puts has nothing to do with any of this. You can repeat it until next week, but it has absolutely nothing to do with any of this. Nothing. I’ll repeat myself: nothing. The original issue is not what was presented via the puts (or print, as somebody else said, which was never part of any discussion…but we move on). It was about the result through the join.
> I’ve been doing stuff like that since the 80’s.
I'm glad you've been programming since I was a wee babby. I've only been doing it since the 90s (Ruby for about a decade.) That's not relevant, though.
Well, you see, it is. First, you just brought it up. Second, don’t assume that everybody else is beneath you.
> Also Matthew, don’t assume I didn’t read the notes on this.
The documentation for Hash#each shows, somewhat abstractly perhaps but consistent with the official Ruby docs idioms, that it returns the receiver unmodified. Hence my request that you read (with emphasis) the documentation. (And they're not notes, they're the official human-readable contract for how the core libraries' APIs behave.)
The resulting object passes the `.class == Hash` test, but a deeper inspection would have shown that the result comes out unmodified by `each`; for example: `p( t.each {|k,v| puts [v, k].join(" => ")} )` would have shown that the final result is identical to `t`, even though I flipped the `k` and `v` inside the loop. Hence my request that you formulate meaningful ways to test hypotheses. Testing a noop that, even if it did something would still end up being a noop, is not very useful. Also note that `[p,k].join("=>")` removes all the quotation marks that would have made it parseable as a Hash of Strings.
So you’re saying they don’t have a data type. Right. That makes no sense at all.
Please don't take my advice as admonishment (unless you've a guilty conscience, and even then...) and certainly don't dismiss me because of your life experiences -- fine whisky improves with age, but in the tech world it's far more common for the synonym of "old" to be "obsolete." Asking for advice on these mailing lists is a great thing; accepting the advice is the hard part.
Please don’t take my correction as an indication you are wrong. Older people are the ones you received any education from. Second, your “advice” holds no water, considering the case. Two strings or symbols, joined with a string, returns a hash, and I said it was interesting and useful. You insist on talking about the puts, which is completely irrelevant, but you feel the need to repeat yourself.
Have a nice day.
Cheers, Bee
···
On Oct 1, 2016, at 8:15 PM, Matthew Kerwin <matthew@kerwin.net.au> wrote:
On 2 October 2016 at 09:19, Bee.Lists <bee.lists@gmail.com> wrote: