[Date Prev] [Date Next] [Thread Prev] [Thread Next] Indexes: Main | Date | Thread | Author

[ba-unrev-talk] More on Ruby


>From "Why You Might Want to Try Ruby"
http://freshmeat.net/articles/view/358/    (01)

Ruby is a "dynamically strongly typed", single-inheritance
     object oriented programming language.    (02)

3.times { print " hey " }  ==> " hey hey hey "
 /^IF .. ^END/.type       ==>  Regexp    (03)

Built-In Types: Array, Hash, String, File, Thread, and Time    (04)

Methods which have a "!" at the end change the object they are
applied to:
    string = " this is a string "
    string.strip!                            ==> "this is a string"
    string.capitalize!                     ==> "This is a string"
    string.gsub!(/string/,"phrase")  ==> "This is a phrase"    (05)

You can extend the built-in types.
Classes can be extended at runtime. (shades of Forth!)    (06)

After this declaration, all objects of type Array in the
program will respond to the rotate! method:
   class Array
      def rotate!
          self.unshift( self.pop)
         return self[0]
      end
    end    (07)

Ruby allows for something called mixins. A mixin is a set of
behaviors or functions defined within a module which can be
included (mixed in) to a class. (YES!!)    (08)

other features: GUI toolkits, distributed object system (dRuby)    (09)

And finally, from the tutorial, it notes that when users of an
object access or modify its attributes, there is no distinction
between methods and variables:
   "In his landmark book Object-Oriented Software Construction,
   Bertrand Meyer calls this the Uniform Access Principle. By hiding
   the difference between instance variables and calculated values,
   you are shielding the rest of the world from the implementation of
   your class. You're free to change how things work in the future
   without impacting the millions of lines of code that use your class.
   This is a big win.    (010)

(I have to agree. It's huge.)    (011)