[Courses] [Ruby] Lesson 0: Installing, References, and your
first homework assignment
Karine Delvare
kproot at nerim.net
Thu Nov 10 09:12:35 EST 2005
Hello! I'm Karine Delvare, french, 27 years old, working as a software
engineer mainly on web application. I have learned and used several
programming languages during my studies and at my jobplaces: C, C++,
C#, a bit of Java, a lot of PHP, Perl. I like object-oriented programming very much, but learned to pay attention to lightness. Now I mostly use PHP at work and C (with GObject) at home, and I remember with a smile the huge slow apps I wrote when .NET was "in"...
I am interested in Ruby out of curiosity. Many times I've been proven
wrong on what I thought was carved in stone about programming languages
and their mechanics, so I would like to have a look at as many as
possible to be able to compare. There is no special task I would like
to do with it, I'll just follow the assignments and maybe I'll come up
with something later on.
I played with tictactoe.rb, found on RubyForge. Here is a sample of
code:
# P1 Turn
puts "Player 1's turn"
puts "Select your space, enter the number that is in the space
you want" disp_board(numspac)
space = gets.to_i # Get the space they want!
while barr[space] != " "
puts "Try again that one is taken!!!"
disp_board(numspac)
space = gets.to_i
end
barr[space] = "X"
# End of Turn
disp_board(barr)
check3row(barr)
# P2 Turn
[...]
Simple code with some input/output: asks the player where he wants to
play, check whether the space is free, display the updated board, check
if someone won. I don't understand the details of each line yet, but
Ruby seems like pretty east to read.
Karine.
More information about the Courses
mailing list