本帖最后由 taroxd 于 2015-8-20 19:29 编辑
墨凌羽 发表于 2015-8-20 18:44
想起折腾ruby 差不多有一个月的时间再折腾字符串处理之类的【csv读取、xml读取、括弧匹配什么的 ...
Ruby 真简单,看了楼主的「提示」就坚决不想学 Java 了
Student = Struct.new(:stuNo, :name) do def equals(others) self.stuNo == others.stuNo end def toString "姓名:#{name}\t学号:#{stuNo}" end end month, day, year = gets.split('/') "#{year}年#{month}月#{day}日", year, month, day "随机字符串".count 'A-z' "随机字符串".count '0-9' "一段歌词".scan('朋友').size "有敏感词的内容".gsub Regexp.union('敏感词', '内容'), ''
Student = Struct.new(:stuNo, :name) do
def equals(others)
self.stuNo == others.stuNo
end
def toString
"姓名:#{name}\t学号:#{stuNo}"
end
end
month, day, year = gets.split('/')
"#{year}年#{month}月#{day}日", year, month, day
"随机字符串".count 'A-z'
"随机字符串".count '0-9'
"一段歌词".scan('朋友').size
"有敏感词的内容".gsub Regexp.union('敏感词', '内容'), ''
|