首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

Ruby_非一般语法糖_Range和if

2012-11-01 
Ruby_特殊语法糖_Range和if题目:irb(main):025:0 if( 3 .. nil)irb(main):026:1puts 100irb(main):027:1

Ruby_特殊语法糖_Range和if

题目:

irb(main):025:0> if( 3 .. nil)irb(main):026:1>   puts 100irb(main):027:1> end100=> nilirb(main):028:0> 3 .. nilArgumentError: bad value for rangefrom (irb):28from :0irb(main):029:0>

?

关闭:

?

If range expression appears in any other place than conditional expression, it returns range object from left hand side to right hand side.

?

If range expression appears in conditional expression, it gives false until left hand side returns true, it stays true until right hand side is true. .. acts like awk, ... acts like sed.

?

参考:ruby的语法:

http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/syntax.html

?

?

====END====

====END====

====END====

+++

热点排行