Difference between revisions of "Ruby"
From Suhrid.net Wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | = Philosophy = | + | = Philosophy = |
* Focus is on the programmer rather than the machine. i.e. maximize programmer efficiency. | * Focus is on the programmer rather than the machine. i.e. maximize programmer efficiency. | ||
Line 9: | Line 9: | ||
** Object oriented : everything is an object | ** Object oriented : everything is an object | ||
** Functional : Also exists. Computation proceeds via the evaluation of functions that depend only on their input, not program state. | ** Functional : Also exists. Computation proceeds via the evaluation of functions that depend only on their input, not program state. | ||
+ | |||
+ | = Classes and Inheritance = | ||
+ | |||
+ | <syntaxhighlight lang="ruby"> | ||
+ | |||
+ | class MyClass | ||
+ | @boo #instance variable | ||
+ | def my_method | ||
+ | @foo = 2 | ||
+ | end | ||
+ | end | ||
+ | |||
+ | </syntaxhighlight> |
Revision as of 09:50, 3 September 2014
Philosophy
- Focus is on the programmer rather than the machine. i.e. maximize programmer efficiency.
- Principle of least astonishment - behave in such a way that minimized the confusion of experienced Ruby programmers.
- Ruby is an object-oriented scripting language.
- Multi paradigm :
- Scripting : automate tasks within some environment
- Imperative : traditional control structures
- Object oriented : everything is an object
- Functional : Also exists. Computation proceeds via the evaluation of functions that depend only on their input, not program state.
Classes and Inheritance
class MyClass
@boo #instance variable
def my_method
@foo = 2
end
end