DEV Community

Cover image for Twiddle-wakka (Yes, that's a real thing)
Drew Bragg
Drew Bragg

Posted on

Twiddle-wakka (Yes, that's a real thing)

You may or may not know that Ruby has a pessimistic operator:

~>
Enter fullscreen mode Exit fullscreen mode

It's actually a pretty cool little thing used in Gemfiles to specify a version range.

gem 'rails', '~> 5.2.1'
gem 'devise', '~> 4.6'
gem 'puma', '~> 3'
Enter fullscreen mode Exit fullscreen mode

is the same as specifying:

gem 'rails', '>= 5.2.1', '< 5.3.0'
gem 'devise', '>= 4.6.0', '< 5.0'
gem 'puma', '>= 3.0', '< 4.0'
Enter fullscreen mode Exit fullscreen mode

But what is even better about it is it's name. ~> is called a twiddle-wakka

I hope you laughed as much at this as I did.

Happy Friday!

Discussion (2)

Collapse
ahferroin7 profile image
Austin S. Hemmelgarn

This ranks right up there IMO with Python calling it's new := operator the 'walrus operator'.

Collapse
drbragg profile image
Drew Bragg Author

๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚