apdm apdm - 5 months ago 9
Ruby Question

Why does the same code I write using vim not work when I write it in the TextEdit application?

If I write a simple function like this using vim

def hello
"Hello!"
end


and run it, it works fine.

If I create a blank
.rb
file using vim, but then open it with TextEdit and write the exact same thing

def hello
"Hello!"
end


I get this issue

undefined local variable or method `”' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f9f64043548>


I have tried it with other functions as well, and I still get an issue (although its a different one).

In addition, if I open the blank
.rb
file, and do a copy/paste of the same code from elsewhere and then run, it works ok again. It's only if I manually type something using the TextEdit application.

Answer

and " are different characters. The first is the one in your error message, the second is the correct double quote you need to use.

TextEdit is using fancy quotes, replacing the double quote with right and left quotes. You need to turn that off.

Comments