Alpha | Ruby

加減乘除
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Exponentiation 指數(**)
Modulo (%)
輸入/輸出
puts "What's up?" print "Oxnard Montalvo"
找出資料夾
字串的打法
1.%+變數名稱

1
2
3
name1 = "Joe"
name2 = "Mary"
puts "Hello %s, where is %s?" % [name1, name2]
2.#{}

1
2
3
name1 = "Joe"
name2 = "Mary"
puts "Hello #{name1}, where is #{name2}?"
gets.chomp
require模組/函式庫/功能
require 'open-uri'

open("http://www.ruby-lang.org/en") do |f|
  f.each_line {|line| p line}
  puts f.base_uri         # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
  puts f.content_type     # "text/html"
  puts f.charset          # "iso-8859-1"
  puts f.content_encoding # []
  puts f.last_modified    # Thu Dec 05 02:45:02 UTC 2002
end
ARGV解包(unpack)

评论

热门博文