Writing Methods

How many things should a method ideally do?

Just ONE


What types of things should a method modify?

Any type of data.


What should you name a method?

Method names in Ruby may contain upper-case and lower-case letters, numbers, underscores _ and the punctation signs !, ?, =.

A method name can’t begin with a number, and the characters !, ? and = can only appear at the end.

Non-ASCII characters can be used in a method name, but this can lead to very confusing situations and should not be common practice.


What does self mean?

This means that the intended code will apply only to the current instance of the class,


What do you need to do to create your own Ruby script file?

a computer that can save a text file with a .rb extension, basically any computer with the most basic text editor.


How would you run a Ruby script from the command line?

First you need to make sure that you have Ruby enviroment and requested gems install and updated.

Go (cd ….) to the directory where the .rb file is located.

Then type: ruby name_of_file.rb and hit enter.



Copyright 2017. All rights reserved.

Posted December 12, 2016 by Edmundo in category "Daily