I am using eval to dynamically define a method, and at some point, I want to
do this:
raise "Invalid type: #{val}“
Except that this is inside an eval’d string, and so #{val} gets evaluated the
first time, and at this point val doesn’t exist. I’ve tried all sorts of
things like
raise “Invalid type: #{”#{val}”}"
but none of them quite do what I want. I eventually settled for
raise "Invalid type: " + val.to_s
but it still raises the question, how do you force a #{…} not to be
evaluated?
I am using eval to dynamically define a method, and at some point, I want to
do this:
raise “Invalid type: #{val}”
Except that this is inside an eval’d string, and so #{val} gets evaluated the
first time, and at this point val doesn’t exist. I’ve tried all sorts of
things like
raise “Invalid type: #{”#{val}“}”
but none of them quite do what I want. I eventually settled for
raise "Invalid type: " + val.to_s
but it still raises the question, how do you force a #{…} not to be
evaluated?
Tim Bates
It’s so obvious, it’s easy to miss:
eval %{
def greet name
puts “Hello, #{name}”
end
}
Ah, beautiful. I don’t think I tried this, because Vim still highlights the
#{…} as if the \ wasn’t there, and I tend to trust Vim’s highlighting more
than myself when it comes to syntax. Can whoever’s in charge of the standard
Vim syntax highlighting file fix this please? Assuming they read -talk…
Tim Bates
···
On Tue, 18 Mar 2003 6:49 pm, Joel VanderWerf wrote:
It’s so obvious, it’s easy to miss:
eval %{
def greet name
puts “Hello, #{name}”
end
}
eval %{
def greet name
puts “Hello, #{name}”
end
}
Ah, beautiful. I don’t think I tried this, because Vim still highlights the
#{…} as if the \ wasn’t there, and I tend to trust Vim’s highlighting more
than myself when it comes to syntax.
I would strongly recommend that you reconsider your position.
Can whoever’s in charge of the standard
Vim syntax highlighting file fix this please? Assuming they read -talk…
Thanks, I’ll fix it.
Regards,
Doug
···
On Tue, Mar 18, 2003 at 06:19:41PM +0900, Tim Bates wrote:
On Tue, 18 Mar 2003 6:49 pm, Joel VanderWerf wrote:
Can whoever’s in charge of the standard
Vim syntax highlighting file fix this please? Assuming they
read -talk…
Thanks, I’ll fix it.
Regards,
Doug
Doug,
Have you thought of keeping this in
the RAA?
Granted it’s not brain surgery, but it’s
useful to many of us, and that would be
a good place to find it. (And after all,
there are things in the RAA that are
nearly useless or nonexistent.)