关键词:
for number in 1..30
puts number
end
------
for number in 1..30
if number == 5
puts "I like 5"
end
puts number
end
rubyonrails-basics.rb
Ruby Copy Raw
The "Hello world!" program is a simple program that displays some text on the screen.
ruby -v - what version is running
treehouse:~/workspace$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
treehouse:~/workspace$ irb
irb(main):001:0> puts "Hello world"
Hello world
=> nil
irb(main):002:0>
Exit irb:
irb(main):001:0> exit
Create a file called "hello.rb" and place the following in the file:
puts "Hello World!"
Run the program we just created by typing the following:
ruby hello.rb
Rules
irb(main):001:0> exit
Create a file called "hello.rb" and place the following in the file:
puts "Hello World!"
Run the program we just created by typing the following:
ruby hello.rb
------------
puts
put string on the screen
gets
get string input
-------------
Create a variable name = "priss"
file
name = "priss"
puts "hello"
puts name
console
treehouse:~/workspace$ ruby hello.rb
hello
Jason
-------------
Put name on 1 line
name = "Jason"
puts "hello #name!"
treehouse:~/workspace$ ruby hello.rb
hello Jason!
-------------
print "Please enter your name: "
name = gets
puts "hello #name!"
treehouse:~/workspace$ ruby hello.rb
Please enter your name: priss
hello priss
!
treehouse:~/workspace$
-------------
Print out your name:
name = "Jason"
puts "Hello #name"
Get input from the user:
name = gets
puts "Hello #name"
Run a Ruby program called "hello.rb":
ruby hello.rb
Prompt the user for their name:
print "Please enter your name: "
name = gets
puts "Hello #name"
#
ruby红宝石操场(代码片段)
查看详情
ruby红宝石产量(代码片段)
查看详情
ruby红宝石操场(代码片段)
查看详情
ruby红宝石尾巴(代码片段)
查看详情
ruby红宝石操场(代码片段)
查看详情
ruby红宝石操场(代码片段)
查看详情
ruby红宝石操场(代码片段)
查看详情
ruby红宝石句子(代码片段)
查看详情
ruby红宝石战士(代码片段)
查看详情
ruby错误的红宝石代码(代码片段)
查看详情
ruby红宝石redis(代码片段)
查看详情
ruby红宝石メモ(代码片段)
查看详情
ruby红宝石的翻译(代码片段)
查看详情
ruby命题逻辑,红宝石(代码片段)
查看详情
ruby红宝石,铁轨书籍(代码片段)
查看详情
ruby红宝石csv(代码片段)
查看详情
ruby红宝石paulcantrell关闭(代码片段)
查看详情
ruby红宝石控制台(代码片段)
查看详情