york

Ruby Methods and Optional parameters

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm playing with Ruby on Rails and I'm trying to create a method with optional parameters. Apparently there are many ways to do it. I trying naming the optional parameters as hashes, and without defining them. The output is different. Take a look: # This functions works fine! def my_info ( name , options = {}) age = options [: age ] || 27 weight = options [: weight ] || 160 city = options [: city ] || "New York" puts "My name is #{name}, my age is #{age}, my weight is #{weight} and I live in {city}" end my_info "Bill" -> My name is

python基础内容整理(一)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 02:07:04
基本数据类型 字符串 String 字符串是不可变类型 字符串的分割: s.split(sep)以给定的sep为分隔符对s进行分割。 In [4]: s = "hello world" s.split() Out[4]: ['hello', 'world'] In [11]: line = "1,2,3,4,5" numbers = line.split(',') 连接 与分割相反,s.join(str_sequence)的作用是以s为连接符将字符串序列str_sequence中的元素连接起来,并返回连接后得到的新字符串: In [13]: s = ',' s.join(numbers) Out[13]: '1,2,3,4,5' 替换 s.replace(part1, part2)将字符串s中指定的部分part1替换成想要的部分part2,并返回新的字符串。 每个部分都会替换 不止是第一个 s的值本身没有发生变化 只是生成一个新的字符串 In [17]: s = "hello world" s.replace('l', ' python ') Out[17]: 'he python python o wor python d' In [19]: s Out[19]: 'hello world' 大小写转换 s.upper()方法返回一个将s中的字母全部大写的新字符串。 s

Oracle SQL多表查询

回眸只為那壹抹淺笑 提交于 2019-11-26 21:39:22
曾经一段时间我对oracle的多表查询搞的云里雾里,究其原因:oracle自己的语法和SQL国际标准语法混用。此文章仅适合oracle 菜鸟,老鸟直接飞过… 多表连接类型(SQL 1999标准) • Cross joins • Natural joins • USING clause • Full (or two-sided) outer joins • Arbitrary join conditions for outer joins SQL1999语法: SELECT table1.column, table2.column FROM table1 [CROSS JOIN table2] | [NATURAL JOIN table2] | [JOIN table2 USING (column_name)] | [JOIN table2 ON (table1.column_name = table2.column_name)]| [LEFT|RIGHT|FULL OUTER JOIN table2 ON (table1.column_name = table2.column_name)]| [CROSS JOIN table2]; 语法解释: table1.column --指明从中检索数据的表和列 CROSS JOIN --返回两个表的笛卡尔集 NATURAL JOIN -