tenderlovemaking.com/2015/02/11/weird-stuff-with-hashes

Preview meta tags from the tenderlovemaking.com website.

Linked Hostnames

3

Search Engine Appearance

Google

https://tenderlovemaking.com/2015/02/11/weird-stuff-with-hashes

Weird stuff with hashes

Ok, so this isn’t really weird stuff, I don’t think. But maybe people don’t know about it so I thought I would post. Hashes dup string keys When you assign a string key to a hash, the hash copies the string and freezes it. Here is an example: >> x = 'string' => "string" >> y = {} => {} >> y[x] = :value => :value >> { x => y.keys.first } => {"string"=>"string"} >> { x.object_id => y.keys.first.object_id } => {70157126548460=>70157126526760} # object ids are different >> { x.frozen? => y.keys.first.frozen? } => {false=>true} # frozen value is different You can prevent the string from being duped by freezing the string before putting it in the hash:



Bing

Weird stuff with hashes

https://tenderlovemaking.com/2015/02/11/weird-stuff-with-hashes

Ok, so this isn’t really weird stuff, I don’t think. But maybe people don’t know about it so I thought I would post. Hashes dup string keys When you assign a string key to a hash, the hash copies the string and freezes it. Here is an example: >> x = 'string' => "string" >> y = {} => {} >> y[x] = :value => :value >> { x => y.keys.first } => {"string"=>"string"} >> { x.object_id => y.keys.first.object_id } => {70157126548460=>70157126526760} # object ids are different >> { x.frozen? => y.keys.first.frozen? } => {false=>true} # frozen value is different You can prevent the string from being duped by freezing the string before putting it in the hash:



DuckDuckGo

https://tenderlovemaking.com/2015/02/11/weird-stuff-with-hashes

Weird stuff with hashes

Ok, so this isn’t really weird stuff, I don’t think. But maybe people don’t know about it so I thought I would post. Hashes dup string keys When you assign a string key to a hash, the hash copies the string and freezes it. Here is an example: >> x = 'string' => "string" >> y = {} => {} >> y[x] = :value => :value >> { x => y.keys.first } => {"string"=>"string"} >> { x.object_id => y.keys.first.object_id } => {70157126548460=>70157126526760} # object ids are different >> { x.frozen? => y.keys.first.frozen? } => {false=>true} # frozen value is different You can prevent the string from being duped by freezing the string before putting it in the hash:

  • General Meta Tags

    7
    • title
      Tenderlove Making - Weird stuff with hashes
    • Content-Type
      text/html; charset=utf-8
    • viewport
      width=device-width, initial-scale=1.0
    • article:section
      posts
    • article:published_time
      2015-02-11T09:45:25-08:00
  • Open Graph Meta Tags

    6
    • og:url
      https://tenderlovemaking.com/2015/02/11/weird-stuff-with-hashes/
    • og:site_name
      Tenderlove Making
    • og:title
      Weird stuff with hashes
    • og:description
      Ok, so this isn’t really weird stuff, I don’t think. But maybe people don’t know about it so I thought I would post. Hashes dup string keys When you assign a string key to a hash, the hash copies the string and freezes it. Here is an example: >> x = 'string' => "string" >> y = {} => {} >> y[x] = :value => :value >> { x => y.keys.first } => {"string"=>"string"} >> { x.object_id => y.keys.first.object_id } => {70157126548460=>70157126526760} # object ids are different >> { x.frozen? => y.keys.first.frozen? } => {false=>true} # frozen value is different You can prevent the string from being duped by freezing the string before putting it in the hash:
    • US country flagog:locale
      en_us
  • Link Tags

    5
    • alternate
      /atom.xml
    • apple-touch-icon
      /apple-touch-icon.png
    • icon
      /favicon.ico
    • stylesheet
      /stylesheet/syntax.css
    • stylesheet
      /stylesheet/main.css

Links

6