Ruby Tutorial 2 - Variables
Loading...
5,300
Loading...
Uploader Comments (gubid)
see all
All Comments (37)
-
@masterlobo The point is, if you only want to read a variable you don't need to be able to write to it.
-
@eternity899 Nevermind, found it. (L)
-
Umm missing videos much?
-
@papiertig0r you probably should try ctrl+shift to put your keyboard into main settings ;)
-
1 Person isn't patient...
-
@pixiri21 same for me!
Loading...
awesome tut, but you forgot something important hehehe. You guided us through attr_reader, attr_writer to just tell us that attr_accessor does both. Is there any downside to using attr_accessor? I don't see the point of attr_reader, attr_writer if there is no downside to attr_accessor :O
tyvm btw! :)
masterlobo 2 weeks ago
@masterlobo In the world of RPG Maker its not that important. But say for example you want to only read a variable and never be able to modify it from an outside line. In that case, you would use a reader, or just a method that returns the internal value. There are many reasons to 'not allow others to break you' in programming, and that is one of the major reasons for 'read only' effective fields.
gubid 1 week ago
Oshiete kudasai!!!
reyearth2040 3 months ago
@reyearth2040 Not sure what that means, but I will assume its good. :)
gubid 2 months ago
I need your help please. I'm not an English speaker, so I could't understand all you said. For example, can you say me why did you create myclass = MyClass new? It's a local variable right? but, doesn't it need to be into a method because local variables serve just for the methods into they were created? Why did you put dot new? How did you indicate the window message to appear when the game starts? myclass(dot)hi activated the method hi from the class myclass isn't it?
reyearth2040 3 months ago
@reyearth2040 When you use the .new method of a class, you are saying to create another instance of it. In this case I stored that newly created instance in the local variable of myclass. Directly after creating, I called a method from within the class, this was the 'hi' method we defined. Hopefully this is helpful.
gubid 2 months ago