D
Dirk Einecke
Hi.
I've a class to get all vars from params:
class CgiParamsToLocal
def initialize(params)
@params = params
end
def method_missing(m, *other)
@params[m.to_s][0]
end
end
Using:
p = CgiParamsToLocal.new($cgi.params)
No I want to check if for example p.foo ist defined. I tried it like this:
print p.foo # -> Test
if ( defined?(p.foo) ) then
# do something
else
# do some other things
end
Well - p.foo is defined but why I ever get only the else part?
If I do it like this all is okay:
print p.foo # -> Test
if ( p.foo.length != 0 ) then
# do something
else
# do some other things
end
Now - why is defined? not working in my example?
greetings
Dirk Einecke
I've a class to get all vars from params:
class CgiParamsToLocal
def initialize(params)
@params = params
end
def method_missing(m, *other)
@params[m.to_s][0]
end
end
Using:
p = CgiParamsToLocal.new($cgi.params)
No I want to check if for example p.foo ist defined. I tried it like this:
print p.foo # -> Test
if ( defined?(p.foo) ) then
# do something
else
# do some other things
end
Well - p.foo is defined but why I ever get only the else part?
If I do it like this all is okay:
print p.foo # -> Test
if ( p.foo.length != 0 ) then
# do something
else
# do some other things
end
Now - why is defined? not working in my example?
greetings
Dirk Einecke