Jump to content
MakeWebGames

Got Rails?


Spudinski

Recommended Posts

I thought I'd share the following: A quite entertaining way of learning Ruby.

The guided tutorials are simple enough for anyone to get, though some parts of the language will be more familiar with experienced developers.

http://tryruby.org

An awesome site, it consists of a basic set of lessons to get you used to the language and interpreter.

http://railsforzombies.org/

I love their videos, even though it's a bit lengthy for those who just want to jump in.

In all, pretty decent way of getting acquainted with RoR.

S.

Edited by Spudinski
Updated links...
Link to comment
Share on other sites

Ruby's intention is to be fun to use, and to be as expressive and clean as possible.

While the syntax is a bit on the "awkward" side for PHP developers, it may resemble some point of Javascript.

Edit: See http://www.slideshare.net/DefV/rails-advantages-and-techniques, it explains below in depth.

The things I personally find amusing from Ruby is:

- Ability to join methods to each other, much like one would do in Javascript(jQuery users will like this).

Example:

post = <<-"."
   Rails
   on
   Ruby
   .

print post.lines.to_a.reverse.join

 

Output:

Ruby
on
Rails

 

- Simple typecasting & conversion of variables, though it may be difficult to learn for first timers.

Example:

"50".to_i * 2 

Output:

100

PS. PHP developers may be used to "50" * 2 = 100
In ruby, it's "5050".

 

- Easy arrays, although arrays alone can not contain key=>val like PHP user would know. key=>val is done by Hashes.

Example:

long_array = Array.new
short_array = []
other_array = [a, b, c]
another_array = %w[a b c]
array_one   = %w'a b c'
array_two   = 'a b c'.split

 

- Ranges, "A range represents a subset of all possible values of a type, to be more precise, all possible values between a start value and an end value."

Example:

'a'..'z'
0..0
0.1...1.0

r = 'a'..'d'
puts r === 'c' // check if c is in range
true

 

- % Notations, and modifiers.

Any single non-alpha-numeric character can be used as the delimiter, %[including these], %?or these?, %~or even these things~.

[TABLE=class: wikitable, width: 1]

[TR]

[TD]Modifier[/TD]

[TD]Meaning[/TD]

[/TR]

[TR]

[TD]%q[ ][/TD]

[TD]Non-interpolated String (except for \\ \[ and \])[/TD]

[/TR]

[TR]

[TD]%Q[ ][/TD]

[TD]Interpolated String (default)[/TD]

[/TR]

[TR]

[TD]%r[ ][/TD]

[TD]Interpolated Regexp (flags can appear after the closing delimiter)[/TD]

[/TR]

[TR]

[TD]%s[ ][/TD]

[TD]Non-interpolated Symbol[/TD]

[/TR]

[TR]

[TD]%w[ ][/TD]

[TD]Non-interpolated Array of words, separated by whitespace[/TD]

[/TR]

[TR]

[TD]%W[ ][/TD]

[TD]Interpolated Array of words, separated by whitespace[/TD]

[/TR]

[TR]

[TD]%x[ ][/TD]

[TD]Interpolated shell command[/TD]

[/TR]

[/TABLE]

Edited by Spudinski
code tags, takes getting used to...
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...