BeautifyRuby icon indicating copy to clipboard operation
BeautifyRuby copied to clipboard

Special variable like $` causes mess

Open hongliang-goudou opened this issue 12 years ago • 0 comments

class A
  def foo
    "abc" =~ /\w+/
    puts $`
  end

  def bar
  end
end

After BeautifyRuby runs, it turns out to be:

class A
  def foo
    "abc" =~ /\w+/
    puts $`
  end

  def bar
      end    #### <---- wrong!
end

A temporary workaround is:

class A
  def foo
    "abc" =~ /\w+/
    puts $` #`    <------ workaround!
  end

  def bar
  end
end

Some other special ruby variables, such as $', $, $+, etc, would cause more serious problem than $`. They are not easy to workaround. So we need special treatment for these special variables.

hongliang-goudou avatar Jul 17 '13 09:07 hongliang-goudou