Ruby Tutorial 2 - Variables

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
5,300
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Apr 10, 2011

Understanding how to set and manipulate variables is extremely important in programming. Without variables, we could not store and read information and therefor programming would not be very helpful to anyone. This tutorial aims to help you understand the different types of variables and how to read/write to them from within or outside that class. This will give you a good base on how and why we define variables for future tutorials.

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (gubid)

  • 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 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.

  • Oshiete kudasai!!!

  • @reyearth2040 Not sure what that means, but I will assume its good. :)

  • 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 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.

see all

All Comments (37)

Sign In or Sign Up now to post a comment!
  • @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...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more