#!
/usr/bin/ruby
print Hello Ruby
Yukihiro (Matz) Matsumoto
PHP.rb
- dynamically typed
- controll access : public, protected and
private
- some vars start $
- string interpolation and : #{foo}
- true, false
- [] ...
just that
-
null is called nil
need to convert between types
(), return, are optional
no abstract classes or interfaces
{} and [] are not interchangeable
false, nil => FALSE
0, [], {} and => TRUE
Everything is an Object
class Numeric < Parintele
def to_square
self * self
end
end
2.to_square => 4
Modules and Mixins
- modules define reusable pieces of code
that couldnt be instantiated.
- modules provides a namespace
- modules could be mixin to any class
that satisfy : Should quack and swim like a
duck.
codingguidelines
- localVariable
-@instanceVariable
-@@classVariable
-$globalVariable
-CONSTANT
-ClassName
special slide for ...
VLAD
method_name
Ruby variables hold references to objects
and the = operator copies the references.
In order to get a object that won't change
out from under you, you need to dup or
clone the object you're passed, thus giving
an object that nobody else has a reference
to.
Constants are little more than a
convention. If you try to modify a constant
that's already been assigned to, you'll get a
warning. More or less, Ruby sees them as
no different from any other variable, and
when you try to assign to any variable that
begins in a capital letter and already
exists, it prints a warning on standard
error.
if/unless/ ELSIF
case/when/then
Loops - while, for, until, break, redo and
retry