Computer Science Canada Ruby... from Turing |
Author: | HyperFlexed [ Sun Nov 21, 2004 2:37 am ] |
Post subject: | Ruby... from Turing |
I decided to learn another language... I downloaded freeRide, but now I have no idea what to do. I've tried writing a few programs, but when I run them, the program crashes. I have a few questions. how do I declare a variable? how do I initialize a variable? how do I display something? how would this be written in Ruby? (put "A string mixed with ", aNumVar) Also, could someone show me the HelloWorld program in Ruby? I tried finding my own tuts, but damn. There is all this amazingly intimidating jargon all over the pages, and I don't know wtf is going on. |
Author: | Tony [ Sun Nov 21, 2004 4:22 am ] | ||||
Post subject: | |||||
|
Author: | HyperFlexed [ Sun Nov 21, 2004 12:56 pm ] |
Post subject: | |
wow... interesting. No formal varaible declarations. I have another question, are programming blocks in any way like procedures and functions? It would make sense because any variable "declared" in them are not global. thx alot btw.. I think when I get the hang of Ruby I'm going to write a big tutorial from an idiots POV. |
Author: | HyperFlexed [ Sun Nov 21, 2004 12:57 pm ] |
Post subject: | |
P.S, anyone know any good IDE's for Ruby? I'm not really liking FreeRIDE at all. Should it just run my programs? or do I have to install some kind of Ruby thingamajigger? |
Author: | wtd [ Sun Nov 21, 2004 2:15 pm ] |
Post subject: | |
HyperFlexed wrote: P.S, anyone know any good IDE's for Ruby? I'm not really liking FreeRIDE at all. Should it just run my programs? or do I have to install some kind of Ruby thingamajigger?
For learning the basics, use IRB. Start -> Run, then type "irb" and hit enter. |
Author: | HyperFlexed [ Sun Nov 21, 2004 2:18 pm ] |
Post subject: | |
wtd wrote: HyperFlexed wrote: P.S, anyone know any good IDE's for Ruby? I'm not really liking FreeRIDE at all. Should it just run my programs? or do I have to install some kind of Ruby thingamajigger?
For learning the basics, use IRB. Start -> Run, then type "irb" and hit enter. ummmm... I think I need to install something first because that didn't work. |
Author: | wtd [ Sun Nov 21, 2004 2:28 pm ] | ||||||||||||||||
Post subject: | |||||||||||||||||
HyperFlexed wrote: wow... interesting. No formal varaible declarations.
No, you don't have to declare variables. It can be a real time-saver. HyperFlexed wrote: I have another question, are programming blocks in any way like procedures and functions? It would make sense because any variable "declared" in them are not global.
Somewhat. There are a few ways of creating a block. We can either explicitly create a new Proc object:
We can use the lamnda method, which often jives better with math people:
And now, if we have a function which takes a block as an argument... The & indicates the argument is a block
We can either call it using the existing block:
Or we can pass it a new block:
The other way to use a block with a function is to "yield" the variables out to any block that might be included.
And we can call it in the same way:
The power of this, vs. other methods in other languages is... what if I want to multiply two and two?
|
Author: | wtd [ Sun Nov 21, 2004 2:30 pm ] |
Post subject: | |
HyperFlexed wrote: wtd wrote: HyperFlexed wrote: P.S, anyone know any good IDE's for Ruby? I'm not really liking FreeRIDE at all. Should it just run my programs? or do I have to install some kind of Ruby thingamajigger?
For learning the basics, use IRB. Start -> Run, then type "irb" and hit enter. ummmm... I think I need to install something first because that didn't work. http://rubyinstaller.rubyforge.org/wiki/wiki.pl |
Author: | HyperFlexed [ Sun Nov 21, 2004 6:01 pm ] |
Post subject: | |
all those code examples, are all of those things keywords or something? ruby is very minimalist. I think it's retarted. |
Author: | Tony [ Sun Nov 21, 2004 6:25 pm ] |
Post subject: | |
I think you should take a break... *click click* We'll see you tomorrow |
Author: | wtd [ Sun Nov 21, 2004 7:41 pm ] |
Post subject: | |
HyperFlexed wrote: all those code examples, are all of those things keywords or something?
Only "def", "end", ".", and the basic "{ | | }" construct are part of the syntax. "Proc" is a class, "new" is a method of that class, "two_and_two" is a user-defined method, and "lambda" is a method of the Object class. |
Author: | Andy [ Sun Nov 21, 2004 8:00 pm ] |
Post subject: | |
HyperFlexed wrote: ruby is very minimalist. I think it's retarted.
the point of ruby was to be simple, so its not a pain to program |
Author: | wtd [ Sun Nov 21, 2004 8:17 pm ] |
Post subject: | |
dodge_tomahawk wrote: HyperFlexed wrote: ruby is very minimalist. I think it's retarted.
the point of ruby was to be simple And don't forget flexible. |