在一个ruby字符串中包含表但是或者变量.想使用不同的值替换表达式或者变量 1 类似java 或者python的printf-style方式 template = 'Oceania has always been at war with %s.' template % 'Eurasia' # => "Oceania has always been at war with Eurasia." template % 'Eastasia' # => "Oceania h…
以下是2种表达方式一样. if expression code end if expression then #推荐这种形式 code end expression的值不是false或nil,则code块将被执行. 需要注意:1)围绕expressions的圆括号是可选的(而且通常都不用),ruby使用换行符.分号或者关键字then对条件表达式和后续的内容进行分隔 2) 必须以end 作为结束. 例子 if data #if array exist data << x #append x to…
一.String类的特点 1.字符串对象一旦被初始化就不会被改变: (1)常见问题 a public static void main(String[] args) { String a = "abc"; a = "nbc"; System.out.println(a); } 这种不叫作字符串对象改变,只是引用变量a的引用对象发生了改变:真正的"abc"字符串对象并没有改变: b public static void main(String[]…
Ruby学习笔记4: 动态web app的建立 We will first build the Categories page. This page contains topics like Art, Home & Living, and Kids, so our users can browse through categories and find what they like. Each Category in our site will need to store information…