DEV Community

Corey Alexander
Corey Alexander Subscriber

Posted on ā€¢ Originally published at coreyja.com on

String Interning

Today I learned about String Interning. Which is the process of taking a string and turning it into a number that you can use to represent that string. Its often used in cases where you might have a fixed number of strings, and want to perform things like equality checks quicker than doing string equality. You can map each string to a unique integer then do the equality check on the integer instead.

And even cooler I was actually familiar with the concept, just not the name! This is how Strings and Symbols work in Ruby! A Symbol is an 'interned string', that are often used as hash keys in Ruby. This is nice since we don't have to do string hashing on each hash lookup. Pretty neat!

Links:

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

šŸ‘‹ Kindness is contagious

Please leave a ā¤ļø or a friendly comment on this post if you found it helpful!

Okay