lundi 29 août 2016

I am trying to open .rb file but I get an error message "in '

I'm completely new to this and I am following a course to learn coding but I can't seem to open the .rb files I downloaded with the course to follow along. In the video he double clicks the .rb file and command prompt opens with the code but when I double click the file my command prompt opens then immediately closes so I'm trying to open it manually by navigating to the directory where the program is located in command prompt. In ruby I type "cd Desktop" since the .rb file is on my desktop then I type "ruby 02_02integers.rb" which is the name of the file (I press tab after typing "02" since it fills the rest automatically") but when I press enter I get the error message above. This is the code in the .rb file I'm trying to open in command prompt, he's basically just showing different examples of integers.

# This file is a transcript of the IRB session shown in the movie.
# You should be able to cut and paste it into IRB to get 
# the same results shown in the comments.

# irb
1 + 1
# => 2
x = 2
# => 2
4 / 2
# => 2
4 * 2
# => 8
4 - 2
# => 2
4 ** 2
# => 16
x = 4
# => 4
x += 2
# => 6
x
# => 6
x = x + 2
# => 8
(1 + 2) * 3
# => 9
1234.class
# => Fixnum
123456789123456789.class
# => Bignum
x = 1234 * 1234 * 1234
# => 1879080904
x.class
# => Bignum
-200
# => -200
-200.abs
# => 200
200.next
# => 201
quit

Aucun commentaire:

Enregistrer un commentaire