The static of Java and the self of ruby

Is it static in ruby, like self in ruby?

Solution

No, the static nature of Java has nothing to do with Ruby's ego

Java is equivalent to Ruby's ego Ruby's Java equivalent static does not exist

Java's static means that the method is scheduled statically rather than dynamically In ruby, dynamic scheduling methods are always used Static means that the method is not called on any object In ruby, methods are always called on objects Because static methods in Java are not associated with any object, they cannot access any object state In ruby, a method can always access the state of its associated instance

In short, static methods are not real methods at all. They are programs Ruby has no programs, only (instance) methods

There are no constructs in ruby and can even be remotely equivalent to static constructs in Java

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>