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

《guide to ruby》读书笔记一

2012-12-24 
《guide to ruby》读书笔记11、ruby有三种变量:Global variables can be used anywhere in your program. The

《guide to ruby》读书笔记1

1、ruby有三种变量:

Global variables can be used anywhere in your program. They never go out of sight.以$开头

Instance variables,以@开头

Class variables,以@@开头

《guide to ruby》读书笔记一
2、布尔值

The?unless?keyword has a policy of?only allowing those with a negative charge in. Who are:?nil?and?false.

?

And another nice trick: stack the?if?and?unless.

This trick is a gorgeous way of expressing,?Do this only if?a* is true and *b?isn’t true.

?

3、循环

When you are iterating through a list, you may use?next?toskip on to the next item

case year when 1894   "Born." when 1895..1913   "Childhood in Lousville, Winston Co., Mississippi." else   "No information about this year." endif 1894 === year   "Born." elsif 1895..1913 === year   "Childhood in Lousville, Winston Co., Mississippi." else   "No information about this year." end
?

Take the Ranges above.?(1895..1913)?isn’t at all?equal?to?1905. No, the Range?(1895..1913)?is only truly?equal?to any other Range?(1895..1913).

热点排行