[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Question about return and access control

Felipe

3/15/2006 11:00:00 PM

I'm reading PickAxe book and just finished reading chapter 3, which
talks about classes, objects and variables. While this chapter (and the
whole book so far) was very informative, I have two doubts:

- return seems to be used when defining methods and nowhere else. Why
use it (why not use puts)?
- Why and where specify access control (public, protected and private
methods)? The examples in the book weren't clear enough.

Thanks in advance.



12 Answers

gmurray

3/16/2006 5:18:00 AM

0

Felipe wrote:
> I'm reading PickAxe book and just finished reading chapter 3, which
> talks about classes, objects and variables. While this chapter (and the
> whole book so far) was very informative, I have two doubts:
>
> - return seems to be used when defining methods and nowhere else. Why
> use it (why not use puts)?

return <value> and puts <value> are distinctly different.
"puts" always sends the value to STDOUT, and the control passes to the
next statement.
"return" makes the <value> available to its receiver (at the caller of
the method in where the "return" statement exists), and control
transfers to the next statement after that receiver.

> - Why and where specify access control (public, protected and private
> methods)? The examples in the book weren't clear enough.

Chapter 3 is just an introduction to access control. You then know
that there ARE these differences. Why these differences exists, and
how to know what methods of a class or module can be accessed, and
under what circumstances, becomes clearer in later chapters.
When studying class inheritance, you will see that the types of
control affect which of the methods declared are available to an
instance of
a class that has inheritance. Examples there will make the
distinctions
clear. (and the error messages from the interpreter provide any help
needed.) Access control is important concept because it improves the
reliability of the program, and can limit possible bugs.

> Thanks in advance.

Fred J. McCall

12/17/2010 3:41:00 PM

0

William Clark <wclark2@colnospamumbus.rr.com> wrote:

>In article <a3nlg6lju3oeafkfr2hh4o83r4hhnqtgbf@4ax.com>,
> Fred J. McCall <fjmccall@gmail.com> wrote:
>
>> William Clark <wclark2@colnospamumbus.rr.com> wrote:
>>
>> >In article <68idnSGdhrsn2pfQnZ2dnUVZ_vWdnZ2d@giganews.com>,
>> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
>> >
>> >> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
>> >> news:wclark2-FF2A1A.10254616122010@charm.magnus.acs.ohio-state.edu...
>> >> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
>> >>
>> >> >> Certainly you care, otherwise you would have long since abandoned this
>> >> >> futile effort to convince us you know feck all about American driving
>> >> >> tests.
>> >> >> BTW, isn't it to you to back up your assertions rather than Fred and I
>> >> >> to
>> >> >> refute?
>> >> >
>> >> > I have - two taken, plus the UK one. You, on the other hand, have
>> >> > nothing but your silly blather. Again I ask, produce the facts or give
>> >> > it up.
>> >>
>> >> You made the assertion.
>> >> It would be up to you to produce facts.
>> >> So far, all Fred and I have heard is unsubstantiated opinion.
>> >> Over to you, Mister Clark.
>> >
>> >Opinion counts in a court if it is based on observation. Now prove the
>> >opposite.
>> >
>>
>> My opinion, based on observation, is that you are a lying bampot. Case
>> settled (by your rules).
>
>But you have not "observed" a single lie, have you?
>

I haven't observed anything but.

>
>Oh, I no that you
>are desperate to deny the truth,
>

You "no" that, do you? Is this the guy that was engaging in spelling
flames just a bit ago?

<snicker>

>
>but observation means you have actually
>seen the event - and you cannot actually produce one shred of evidence
>that you have. Down in flames again.
>

You think you're communicating (to use the term loosely) where nobody
can see?

Phew, what a maroon!

>
>Game, set, and match.
>

More proof of just how delusional you are.

--
"Ordinarily he is insane. But he has lucid moments when he is
only stupid."
-- Heinrich Heine

conwaycaine

12/17/2010 6:52:00 PM

0


"William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
news:wclark2-5C7293.16303816122010@charm.magnus.acs.ohio-state.edu...
> "conwaycaine" <conwaycaine@bellsouth.net> wrote:

>> >> Certainly you care, otherwise you would have long since abandoned this
>> >> futile effort to convince us you know feck all about American driving
>> >> tests.
>> >> BTW, isn't it to you to back up your assertions rather than Fred and I
>> >> to
>> >> refute?
>> >
>> > I have - two taken, plus the UK one. You, on the other hand, have
>> > nothing but your silly blather. Again I ask, produce the facts or give
>> > it up.
>>
>> You made the assertion.
>> It would be up to you to produce facts.
>> So far, all Fred and I have heard is unsubstantiated opinion.
>> Over to you, Mister Clark.
>
> Opinion counts in a court if it is based on observation. Now prove the
> opposite.

Is this the level of your teaching at Ohio State?
Do you (God forbid) have tenure???


> Oh, I forgot, you can't, hence all the bluster.

Really, this is pathetic.


William Clark

12/17/2010 10:37:00 PM

0

In article <2s0ng65a3glg0nd9tm07p7cg8ek6s42vgs@4ax.com>,
Fred J. McCall <fjmccall@gmail.com> wrote:

> William Clark <wclark2@colnospamumbus.rr.com> wrote:
>
> >In article <u0nlg6p3rgsu253788rsatoie5617rrts0@4ax.com>,
> > Fred J. McCall <fjmccall@gmail.com> wrote:
> >
> >> William Clark <wclark2@colnospamumbus.rr.com> wrote:
> >>
> >> >In article <41dkg6pbt3gdi6ob9flim3g9a976bm6nmt@4ax.com>,
> >> > Fred J. McCall <fjmccall@gmail.com> wrote:
> >> >
> >> >> William Clark <wclark2@colnospamumbus.rr.com> wrote:
> >> >>
> >> >> >In article <oo7kg61fimtmm66iapkojkka181inc06f0@4ax.com>,
> >> >> > Fred J. McCall <fjmccall@gmail.com> wrote:
> >> >> >
> >> >> >> William Clark <wclark2@colnospamumbus.rr.com> wrote:
> >> >> >>
> >> >> >> >In article <3r1jg6tp0npmag5qh8vhmv300le269tb7f@4ax.com>,
> >> >> >> > Fred J. McCall <fjmccall@gmail.com> wrote:
> >> >> >> >
> >> >> >> >> William Clark <wclark2@colnospamumbus.rr.com> wrote:
> >> >> >> >>
> >> >> >> >> >In article <6YadneW3s7bBQJXQnZ2dnUVZ_gmdnZ2d@giganews.com>,
> >> >> >> >> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >> >> >> >> >
> >> >> >> >> >> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in
> >> >> >> >> >> message
> >> >> >> >> >> news:wclark2-77B100.19492713122010@charm.magnus.acs.ohio-state.
> >> >> >> >> >> edu
> >> >> >> >> >> ...
> >> >> >> >> >> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >> >> >> >> >>
> >> >> >> >> >> >> So much for Clarkian infallibility
> >> >> >> >> >> >
> >> >> >> >> >> > Well, I was trying to keep it simple for the hard of
> >> >> >> >> >> > thinking
> >> >> >> >> >> > like
> >> >> >> >> >> > yourself. There is not a lot of difference in the driving
> >> >> >> >> >> > test
> >> >> >> >> >> > from
> >> >> >> >> >> > state to state,
> >> >> >> >> >>
> >> >> >> >> >> Your evidence for that??
> >> >> >> >> >
> >> >> >> >> >They are all a joke.
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >> In case you haven't figured it out by now, nobody is going to
> >> >> >> >> consider
> >> >> >> >> your unsupported assertions as 'evidence'.
> >> >> >> >
> >> >> >> >I could care less. It is my observation, against which not one of
> >> >> >> >you
> >> >> >> >"experts" has yet produced one shred of evidence. Ergo, I win.
> >> >> >> >
> >> >> >>
> >> >> >> And 'winning' is important to you, is it? Well, if you think you
> >> >> >> making unsupported assertions based on your own delusions makes you
> >> >> >> a
> >> >> >> 'winner', why you just go ahead and believe whatever you need to to
> >> >> >> feel all warm and fuzzy...
> >> >> >
> >> >> >Silly boy . . .
> >> >> >
> >> >>
> >> >> No need for you to sign your work, boyo. It's obvious what you are...
> >> >
> >> >Devoid of ideas, is what you are . . . .
> >> >
> >>
> >> One more little gulp and we'll have you hooked through the duodenum.
> >> Come on, guppy, just one more....
> >
> >Now if I toss this little worm out, he is sure to bite on it hard. Here
> >we go . . . .
> >
>
> One more time - do these sorts of infantile tactics EVER work to get
> you that last word that you crave so much? I can't believe they do
> unless you travel in a much, MUCH stupider crowd - say, plant life.
>
> Tell you what. Why don't you go ahead and take it. I wouldn't want
> you to start crying or something...

One more time - is trying to deflect to "tactics" how you slide out of
every discussion that you find yourself on the losing side of? And how
you try to browbeat others into giving you, the great Poohbah, the final
word?

It's rather sad, really.

William Clark

12/17/2010 10:39:00 PM

0

In article <r01ng612l2os4ivr66gcj3rft9ro4nb7p3@4ax.com>,
Fred J. McCall <fjmccall@gmail.com> wrote:

> William Clark <wclark2@colnospamumbus.rr.com> wrote:
>
> >In article <a3nlg6lju3oeafkfr2hh4o83r4hhnqtgbf@4ax.com>,
> > Fred J. McCall <fjmccall@gmail.com> wrote:
> >
> >> William Clark <wclark2@colnospamumbus.rr.com> wrote:
> >>
> >> >In article <68idnSGdhrsn2pfQnZ2dnUVZ_vWdnZ2d@giganews.com>,
> >> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >> >
> >> >> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
> >> >> news:wclark2-FF2A1A.10254616122010@charm.magnus.acs.ohio-state.edu...
> >> >> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >> >>
> >> >> >> Certainly you care, otherwise you would have long since abandoned
> >> >> >> this
> >> >> >> futile effort to convince us you know feck all about American
> >> >> >> driving
> >> >> >> tests.
> >> >> >> BTW, isn't it to you to back up your assertions rather than Fred and
> >> >> >> I
> >> >> >> to
> >> >> >> refute?
> >> >> >
> >> >> > I have - two taken, plus the UK one. You, on the other hand, have
> >> >> > nothing but your silly blather. Again I ask, produce the facts or
> >> >> > give
> >> >> > it up.
> >> >>
> >> >> You made the assertion.
> >> >> It would be up to you to produce facts.
> >> >> So far, all Fred and I have heard is unsubstantiated opinion.
> >> >> Over to you, Mister Clark.
> >> >
> >> >Opinion counts in a court if it is based on observation. Now prove the
> >> >opposite.
> >> >
> >>
> >> My opinion, based on observation, is that you are a lying bampot. Case
> >> settled (by your rules).
> >
> >But you have not "observed" a single lie, have you?
> >
>
> I haven't observed anything but.

Proof?

Oh, sorry, you don;t have any, do you?
>
> >
> >Oh, I no that you
> >are desperate to deny the truth,
> >
>
> You "no" that, do you? Is this the guy that was engaging in spelling
> flames just a bit ago?
>
> <snicker>

Aren't you the guy who doesn't know the difference between "defendent"
and "defendant"?
>
> >
> >but observation means you have actually
> >seen the event - and you cannot actually produce one shred of evidence
> >that you have. Down in flames again.
> >
>
> You think you're communicating (to use the term loosely) where nobody
> can see?
>
> Phew, what a maroon!

The produce your evidence for all to see. Oops, you don't have any, do
you?
>
> >
Game, set, and match.

William Clark

12/17/2010 10:40:00 PM

0

In article <27ednWjH6_ozLZbQnZ2dnUVZ_uudnZ2d@giganews.com>,
"conwaycaine" <conwaycaine@bellsouth.net> wrote:

> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
> news:wclark2-5C7293.16303816122010@charm.magnus.acs.ohio-state.edu...
> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
>
> >> >> Certainly you care, otherwise you would have long since abandoned this
> >> >> futile effort to convince us you know feck all about American driving
> >> >> tests.
> >> >> BTW, isn't it to you to back up your assertions rather than Fred and I
> >> >> to
> >> >> refute?
> >> >
> >> > I have - two taken, plus the UK one. You, on the other hand, have
> >> > nothing but your silly blather. Again I ask, produce the facts or give
> >> > it up.
> >>
> >> You made the assertion.
> >> It would be up to you to produce facts.
> >> So far, all Fred and I have heard is unsubstantiated opinion.
> >> Over to you, Mister Clark.
> >
> > Opinion counts in a court if it is based on observation. Now prove the
> > opposite.
>
> Is this the level of your teaching at Ohio State?
> Do you (God forbid) have tenure???

Do you have a college degree? My guess is no.

conwaycaine

12/18/2010 3:03:00 PM

0


"William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
news:wclark2-2E8C83.17395317122010@charm.magnus.acs.ohio-state.edu...
> In article <27ednWjH6_ozLZbQnZ2dnUVZ_uudnZ2d@giganews.com>,
> "conwaycaine" <conwaycaine@bellsouth.net> wrote:
>
>> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
>> news:wclark2-5C7293.16303816122010@charm.magnus.acs.ohio-state.edu...
>> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
>>
>> >> >> Certainly you care, otherwise you would have long since abandoned
>> >> >> this
>> >> >> futile effort to convince us you know feck all about American
>> >> >> driving
>> >> >> tests.
>> >> >> BTW, isn't it to you to back up your assertions rather than Fred
>> >> >> and I
>> >> >> to
>> >> >> refute?
>> >> >
>> >> > I have - two taken, plus the UK one. You, on the other hand, have
>> >> > nothing but your silly blather. Again I ask, produce the facts or
>> >> > give
>> >> > it up.
>> >>
>> >> You made the assertion.
>> >> It would be up to you to produce facts.
>> >> So far, all Fred and I have heard is unsubstantiated opinion.
>> >> Over to you, Mister Clark.
>> >
>> > Opinion counts in a court if it is based on observation. Now prove the
>> > opposite.
>>
>> Is this the level of your teaching at Ohio State?
>> Do you (God forbid) have tenure???
>
> Do you have a college degree? My guess is no.

Why yes I do.
I've my doctorate in Bullshitery.
You, sir, are one of the better case studies I've encountered.
You are sure to appear in my next monograph.
I think I will entitle it "Gobshite and the Brits".


William Clark

12/18/2010 5:15:00 PM

0

In article <Qr2dnWXjxbHvUZHQnZ2dnUVZ_r2dnZ2d@giganews.com>,
"conwaycaine" <conwaycaine@bellsouth.net> wrote:

> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
> news:wclark2-2E8C83.17395317122010@charm.magnus.acs.ohio-state.edu...
> > In article <27ednWjH6_ozLZbQnZ2dnUVZ_uudnZ2d@giganews.com>,
> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >
> >> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
> >> news:wclark2-5C7293.16303816122010@charm.magnus.acs.ohio-state.edu...
> >> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >>
> >> >> >> Certainly you care, otherwise you would have long since abandoned
> >> >> >> this
> >> >> >> futile effort to convince us you know feck all about American
> >> >> >> driving
> >> >> >> tests.
> >> >> >> BTW, isn't it to you to back up your assertions rather than Fred
> >> >> >> and I
> >> >> >> to
> >> >> >> refute?
> >> >> >
> >> >> > I have - two taken, plus the UK one. You, on the other hand, have
> >> >> > nothing but your silly blather. Again I ask, produce the facts or
> >> >> > give
> >> >> > it up.
> >> >>
> >> >> You made the assertion.
> >> >> It would be up to you to produce facts.
> >> >> So far, all Fred and I have heard is unsubstantiated opinion.
> >> >> Over to you, Mister Clark.
> >> >
> >> > Opinion counts in a court if it is based on observation. Now prove the
> >> > opposite.
> >>
> >> Is this the level of your teaching at Ohio State?
> >> Do you (God forbid) have tenure???
> >
> > Do you have a college degree? My guess is no.
>
> Why yes I do.
> I've my doctorate in Bullshitery.
> You, sir, are one of the better case studies I've encountered.
> You are sure to appear in my next monograph.
> I think I will entitle it "Gobshite and the Brits".

OK, so you have not had the college experience. That calibrates your
pontifications on anything to do with the topic as, as you say, pure BS.

conwaycaine

12/18/2010 8:17:00 PM

0


"William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
news:wclark2-F47799.12151918122010@charm.magnus.acs.ohio-state.edu...
> "conwaycaine" <conwaycaine@bellsouth.net> wrote:
>> >
>> > Do you have a college degree? My guess is no.
>>
>> Why yes I do.
>> I've my doctorate in Bullshitery.
>> You, sir, are one of the better case studies I've encountered.
>> You are sure to appear in my next monograph.
>> I think I will entitle it "Gobshite and the Brits".
>
> OK, so you have not had the college experience. That calibrates your
> pontifications on anything to do with the topic as, as you say, pure BS.

Speaking of experiences in learning institutes, regale us with tales of your
days in a Brit Public School.


William Clark

12/19/2010 5:58:00 PM

0

In article <5MSdnQd1YryWi5DQnZ2dnUVZ_rudnZ2d@giganews.com>,
"conwaycaine" <conwaycaine@bellsouth.net> wrote:

> "William Clark" <wclark2@colnospamumbus.rr.com> wrote in message
> news:wclark2-F47799.12151918122010@charm.magnus.acs.ohio-state.edu...
> > "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> >> >
> >> > Do you have a college degree? My guess is no.
> >>
> >> Why yes I do.
> >> I've my doctorate in Bullshitery.
> >> You, sir, are one of the better case studies I've encountered.
> >> You are sure to appear in my next monograph.
> >> I think I will entitle it "Gobshite and the Brits".
> >
> > OK, so you have not had the college experience. That calibrates your
> > pontifications on anything to do with the topic as, as you say, pure BS.
>
> Speaking of experiences in learning institutes, regale us with tales of your
> days in a Brit Public School.

When you tell us all about your experiences in college.

Oh, you didn't go to college? Too, bad, then you won't get my stories.