Instance_eval("class") error/bug?

if I try someObject.instance_eval(“class”) I get :

in instance_eval': (eval):1:ininstance_eval’: compile error
(SyntaxError)
(eval):1: syntax error
class

I am using PragProgs install for 1.8 for Windows. Is this expected
or a bug?

As a work around I am using send() instead, but I believe I had
tested them in the past and found instance_eval to be faster than
send.

Walt

P.S. Note I am not really doing the above, I am taking a string using
it dynamically, it just happened to crash with “class”

···

Walter Szewelanczyk
IS Director
M.W. Sewall & CO. email : walter@mwsewall.com
259 Front St. Phone : (207) 442-7994 x 128
Bath, ME 04530 Fax : (207) 443-6284


Hello –

···

On Fri, 18 Jul 2003 walter@mwsewall.com wrote:

if I try someObject.instance_eval(“class”) I get :

in instance_eval': (eval):1:in instance_eval’: compile error
(SyntaxError)
(eval):1: syntax error
class

I am using PragProgs install for 1.8 for Windows. Is this expected
or a bug?

It’s expected. Because ‘class’ is also a keyword, you have to specify
its receiver when you want the ‘class’ method:

obj.instance_eval(“self.class”)

David


David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

if I try someObject.instance_eval(“class”) I get :

in instance_eval': (eval):1:in instance_eval’: compile error
(SyntaxError)
(eval):1: syntax error
class

I am using PragProgs install for 1.8 for Windows. Is this expected
or a bug?

I guess it’s expected, you’d have to do self.class to make it work:

class
SyntaxError: compile error
(irb):1: syntax error
from (irb):1
type
(irb):3: warning: Object#type is deprecated; use Object#class
=> Object
“a”.instance_eval{self.class}
=> String

···

On Fri, Jul 18, 2003 at 02:22:07AM +0900, walter@mwsewall.com wrote:


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

win-nt from the people who invented edlin.
– MaDsen Wikholm, mwikholm@at8.abo.fi