Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6439
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: difference between class and object methods |
| Date | Tue, 31 Jan 2012 21:21:26 +0100 |
| Lines | 29 |
| Message-ID | <9or0qdFjmoU1@mid.individual.net> (permalink) |
| References | <c4ed84a5-78ee-442f-80f5-9996b5ffceb7@o12g2000vbd.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net xOE/FiRFc+0BlLJVyaXhWAMSjLp9mjvO+bTzZNmxPoUormX/w= |
| Cancel-Lock | sha1:hXGwYjhDaswCqtDDfKIIVCXAfWs= |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
| In-Reply-To | <c4ed84a5-78ee-442f-80f5-9996b5ffceb7@o12g2000vbd.googlegroups.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:6439 |
Show key headers only | View raw
On 31.01.2012 13:29, Sagy Drucker wrote:
> am i correct when i compare to java, and say:
> object methods in ruby are equivalent object methods in java
> and class methods in ruby are equivalent STATIC functions in java?
>
> also,
> class variables in ruby are equivalent to static variables in java?
Yep, that's mostly correct. But you should rather not bother to use
class variables (those prefixed with @@) but instead should only use
instance variables of a class, e.g.
class X
def self.a_class_method
@@do_not_use_class_variables = 1
@but_use_class_instance_variables = 2
end
end
Reason is that class variables have weird scoping rules which can
produce strange effects.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar
difference between class and object methods Sagy Drucker <sagysrael@gmail.com> - 2012-01-31 04:29 -0800
Re: difference between class and object methods Robert Klemme <shortcutter@googlemail.com> - 2012-01-31 21:21 +0100
Re: difference between class and object methods Rodrigo Kochenburger <divoxx@gmail.com> - 2012-02-01 07:41 -0800
Re: difference between class and object methods Danny Woods <dannywoodz@yahoo.co.uk> - 2012-02-02 21:47 +0000
Re: difference between class and object methods Alec Ross <alec@arlross.demon.co.uk> - 2012-02-03 11:51 +0000
csiph-web