definded? and safe_constantize
2014-04-10 17:59
162 查看
a = 1
defined? a => "local-variable"
defined? b => nil
'hello'.gsub(/正则表达式/, '替换的值') gsub方法的用法就用将一个字符串去匹配参数一中的正则表达式,用第二个参数的值去替换匹配出的字符
' hell0 '.strip 表示去除字符串前后的空格
'hello'.is_a(String) 是判断'hello'是不是String类的一个实例
'Hello'.downcase 将这个字符串中的大写字母转为小写
'Hello'.tableize 将这个字符串转为表的名字比如 'Hello'.tableize--> hellos
Object.freeze 冻结,不能修改的
Object.dup 浅拷贝一份Object对象
'corp'.camelize.safe_constantize.new == Corp.new
'corp'.camelize.safe_constantize.where == Corp.where
defined? a => "local-variable"
defined? b => nil
'hello'.gsub(/正则表达式/, '替换的值') gsub方法的用法就用将一个字符串去匹配参数一中的正则表达式,用第二个参数的值去替换匹配出的字符
' hell0 '.strip 表示去除字符串前后的空格
'hello'.is_a(String) 是判断'hello'是不是String类的一个实例
'Hello'.downcase 将这个字符串中的大写字母转为小写
'Hello'.tableize 将这个字符串转为表的名字比如 'Hello'.tableize--> hellos
Object.freeze 冻结,不能修改的
Object.dup 浅拷贝一份Object对象
'corp'.camelize.safe_constantize.new == Corp.new
'corp'.camelize.safe_constantize.where == Corp.where
相关文章推荐
- jquery常用过滤器选择器
- onchage jquery
- javascript—正则
- 深入理解JavaScript系列(39):设计模式之适配器模式
- SharedPreferences存储读取数据
- spring 返回 JSON乱码问题的解决 及个人 动态加载ztree树结构的json数据代码
- extjs中的recordType
- JavaScript Form Validation 示例
- txtbook简单HTML可读化改造
- 用javascript实现简单排序算法
- (转)JSON数据格式和js操作json总结
- 经典JS的HTML转义与反转义字符
- jQuery仿百度图片浏览效果
- jsp页面中点击(checkbox)或者radio隐藏tr
- BufferedReader源码分析
- 页面布局插件gridster.js
- javascript中不存在块级作用域,所以要小心使用在块级作用域中的函数声明所带来的作用域混乱.
- JSP事件收藏
- javascript获得浏览器工作区域的大小
- jsp工作原理。