ruby好像有指针啊!!!
b = "123"
a = b
b.gsub!(/2/,"")
puts a
得到的结果是13,发现如果a = b的话貌似只是把b的指针给了a,但是如果b的值发生了变化a才能从b中独立出来。
如果把上面的代码改成
b = "123"
a = "#{b}"
b.gsub!(/2/,"")
puts a
则得到的结果为123,这里是把b的值给了a
不知道我的猜想对不对!
相关文档:
http://www.gayathri-frenzy.com/technology/ruby-on-rails
I kept thinking for a while on what do I have next in the store
Here we go “Ruby on Rails”
Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby Programming language.Ruby is a ......
#一、这里是注释,是单行注释,类似于//
puts 3/5#这里是整数形式的结果
puts 3/5.0#这里是小数形式的结果
=begin
这是多行注释,实际上这也是Ruby内嵌文档格式,类似于Java doc
=end不但要有起止,还要缩进才有用。
=end
#二、连行
puts "Hello Ruby!"; puts "This is a "\
"String";# ......
转自:http://developer.51cto.com/art/200912/170762.htm
Ruby字符串处理函数总结列表分享
Ruby字符串处理函数包括返回字符串长度函数;判断字符串中是否包含另一个串函数;字符串插入;字符串分隔,默认分隔符为空格等等。
str.length => integer
str.include? other_str
&nbs ......
When I try the command "gem install thrift" with Ruby 1.9.1, I got a compilation error with something related to a C function "strlcpy()".
Then I searched the web. It seems I am not alone and the community know it.
However I do not want to wait for official update, I want to ......
可用库:getoptlong.rs, optionparser
对应类:GetoptLong, OptionParser
前者已过时,建议使用后者,且后者比前者易用。
后者特点:
1. 参数描述和代码处理写在一起
2. 输出参数说明,不需单独维护
3. 可选参数和命令参数描述简洁
4. 参数可自动转换为特定的类
5. ......