Try and run this in your terminal:
find . -name \*.\*rb -exec perl -p -i -e 's/([^:]):(\w+)\s?(\s*)=>\s?(\s*)/\1\2: \3\4/g' {} \;
find . -name \*.\*rb -exec perl -p -i -e 's/([^:]):(\w+)\s?(\s*)=>\s?(\s*)/\1\2: \3\4/g' {} \;
When working on old Ruby code, you'll see the old (<= 1.9) hash syntax:
{
:name => "Mads",
:age => "25",
:position => "Lead developer"
}
However, often in new projects you'll want to use the new:
{
name: "Mads",
age: "25",
position: "Lead developer"
}
No comments:
Post a Comment