元數(shù)據(jù):數(shù)據(jù)的數(shù)據(jù)
元編程:編程的編程
puts "hello world"
puts("hello world")
a = "hehh"
puts a
a
b = 3
c=2
b+c
b-c
a+b:error
自動推導(dǎo)出類型,像女生那么就是推導(dǎo)為女生類型
查看一個類型所對應(yīng)有哪些方法
1.methods
"aa".methods
在ruby中萬物結(jié)對象,所以ruby中沒有基本的數(shù)據(jù)類型
將數(shù)字轉(zhuǎn)為字符串1.to_s
1.2
1.2.to_s
4-3
4-1.5
0.4-0.3 ??
'2'
"2"
進(jìn)行插值操作
a=2
b=3
"hello #{a+b}"
一個值滿足>=1 and <=2
1..2
一個值滿足>=1 and <3
1...3
字符串*3
irb(main):034:0> "hello" 3
=> "hellohellohello"
為什么字符串可以有,查看對象所有方法:"hello".methods
修改字符串中某一個字符的值
a = "hello"
a[0] = "1"
a
2 ==2
3==1
true.methods
"hello".nil?
"".nil?
"".methods
判斷對象是否為空
"".empty?