7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RubyのHashからファットアローを撲滅せよ

Last updated at Posted at 2014-07-18

ファットアローでRubyのHashを記述するのが許されるのは1.8系までだよね

と言われてしまうのでこれを

旧記法
{
	:hoge     => params[:hoge],
	:fugafuga => params[:fugafuga]
}

こうしたい

新記法
{
	hoge:     params[:hoge],
	fugafuga: params[:fugafuga]
}

正規表現で置換する

検索文字列
":([a-zA-Z_][a-zA-Z0-9_]+)( *) => "
置換文字列
"$1:$2 "

rubymineだったらこんな感じで入力すればOK
スクリーンショット 2014-07-18 22.49.01.png

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?