Upgrade your Ruby hashes to 1.9 with Sublime
In Ruby 1.8 the hashes use syntax a => b
. This was upgraded to the json-like format a: b
for Ruby 1.9 (while the old format is still supported).
Since the JSON-format is easier to read and follows current standards, I encourage you to start upgrading while you make changes in your old codebase. See the very simple step-by-step guide below:
- Open your project in Sublime (or any other editor supporting regex search-and-replace)
- Select Replace... or press
Alt-Cmd-F
- Make sure you have Regular expression selected (the shortcut is
Alt-Cmd-R
) - Type
:(\w*) =>
in Find what: - Type
$1:
in Replace with: - Click Replace All or press
Ctrl-Alt-Enter
Done.
Written by Marko Klemetti
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#