Forum: Ruby scope issues?

1fb34f0596e7f739dfa7c67253fc4a61?d=identicon&s=25 Charles Brotman (chuckbrotman)
on 2017-01-04 00:11
Hi,

I'm relatively new to Ruby and this forum (so please forgive me if I
make any gaffs) and have run into a problem (or two, or
three...).  I think it may be an issue with scope for class method
names, but I'm really not sure what the issue is.  Ruby tells me "no
such
method when I try to call it.  If this is the right place to do it and
it's appropriate, I'll post my source code.  Just let me know I'm in the
right place please. . .
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2017-01-04 08:37
Post your code, but make the code as small (compact) as possible, i.e.
try to find a short example, which exhibits the behaviour.
1fb34f0596e7f739dfa7c67253fc4a61?d=identicon&s=25 Charles Brotman (chuckbrotman)
on 2017-01-04 17:27
Ronald,

Thanks for your reply and suggestion. I had planned to do that. I didn't
want to post a lot of my unpretty Ruby code here unless absolutely
necessary.  However I didn't trust myself to absract the problem
properly.  If I had identified the problem to that degree I probably
wouldn't have needed help debugging it.  In any case I took another
path. I refactored the code and moved the code in question out of the
Class it was in.  (I couldn't really justify having it in a class,
anyway).  It works now, but I still don't know where my problem was.
If anyone can point me to a good description/discussion of class method
scoping issues and declarations that might still be useful...

Thanks again,
Chuck
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2017-01-05 08:42
Charles Brotman wrote in post #1185430:
> If anyone can point me to a good description/discussion of class method
> scoping issues and declarations that might still be useful...

You could read this:
https://www.sitepoint.com/understanding-scope-in-ruby/

Aside, I recommend buying "Programming Ruby" by Dave Thomas. It is
available as PDF at a fair price by "Pragmatic Programmers". Note that
while  this book can also be found for free on some E-Book-Sites, theses
are actually illegal copies.

Ronald
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.