more newbie help with classes and methods please

M

Morton Goldberg

I try (not always successfully) to avoid deeply nested constructs.
When I can't escape nesting, rather than directly nesting, I favor
writing something like:

def case_A
case
when ...
when ...
end
end

def case_B
case
when ...
when ...
end
end

case
when condition_A then case_A
when condition_B then case_B
end

Regards, Morton
 
M

Morton Goldberg

Glad to be of help.

STDIN is indeed a constant defined in Module and its value is the
standard input stream (which is an instance of IO). To me the strange
thing is that Kernel#gets is OK, but Kernel#getc is deprecated.

Regards, Morton
 
L

Logan Capaldo

Glad to be of help.

STDIN is indeed a constant defined in Module and its value is the
standard input stream (which is an instance of IO). To me the
strange thing is that Kernel#gets is OK, but Kernel#getc is
deprecated.

Regards, Morton

Well Kernel#gets is ARGF#gets. ARGF is (in general) for writing well-
behaved filters. Well-behaved filters work on a line by line basis
usually. However ARGF.getc is not deprecated. This makes me think
Kernel#getc is not ARGF.getc, but probably STDIN.getc. This is
inconsistant with Kernel#gets and could thought to be confusing.
Hence its deprecation. Just one man's theory.
 
S

simonh

Very confusing. Surely it would have been easier to keep getc as a
Kernel method. gets and getc are both very similar. Could someone ask
Matz when next they see him?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top