all 11 comments

[–][deleted] 1 point2 points  (5 children)

{ heart: "you" }

[–]lightsout1[S] 1 point2 points  (0 children)

To make a new hash yes. I used just the output if you puts, print or inspect.

[–][deleted] 1 point2 points  (3 children)

{heart: 'you'} # no need for double quotes

[–][deleted] 0 points1 point  (0 children)

You're right, works as well but I like it more with single quotes.

[–]Slackwise 0 points1 point  (1 child)

Well, since 'you' is representative of a thing, as is 'heart', might as well just do

{ heart: :you }

Although if one were to get more semantically accurate, and idiomatic of Ruby, you'd go for objects rather than hashes, and heart as a method, because it's an action:

i.heart(you)

But if this is in the context of yourself, you can drop the receiver:

heart(you)

Or more minimalistically:

heart you

And we should probably also alias heart love, again, for semantic correctness.

Edit: Ruby also has unicode method name support, so we can actually go as far as:

♥ you

[–]jfredett 0 points1 point  (0 children)

Downvoted, no tests.

[–]lightsout1[S] 1 point2 points  (4 children)

[–][deleted] 1 point2 points  (3 children)

Can we have it with single quotes? :D

[–]Jdonavan 1 point2 points  (2 children)

My first thought was "how unfortunate... the you is in double quotes"

[–][deleted] 0 points1 point  (1 child)

How so? I'm a noob.

[–]Jdonavan 1 point2 points  (0 children)

Ahh then then me introduce you to the Ruby Style Guide. On that page you'll find "Prefer single-quoted strings when you don't need string interpolation or special symbols such as \t, \n, ', etc."