一、puts方法:
与print不同的地方在于:显示的字符串最后面一定会换行
eg:
puts('hello','ruby')
执行结果:hello
ruby
二、p方法
可以显示出显示的数字到底是数值还是字符串,原则上解释,p方法是为了观察执行中的程序运行情况
①eg:
p("100") /p(100)
执行结果:“100”/100
②p("hello,\n\truby")
#=>"hello,\n\truby"
三、数学函数
需在程序最前面调用 include Math
或者使用“Math.sin(3.14)”来使用Math模块的函数:
print("sin(3.1415)=",Math.sin(3.1415))
#=>sin(3.1415)=9.265358966049024e-05