首页 > 代码库 > "constantize" and "with_indifferent_access" method
"constantize" and "with_indifferent_access" method
[31] pry(main)> ‘packages‘.classify=> "Package"[33] pry(main)> ‘packages‘.classify.constantize=> Package[40] pry(main)> hash = {key: ‘value‘}=> {:key=>"value"}[41] pry(main)> hash[:key]=> "value"[42] pry(main)> hash[‘key‘]=> nil[44] pry(main)> hash = {key: ‘value‘}.with_indifferent_access=> {"key"=>"value"}[45] pry(main)> hash[:key]=> "value"[46] pry(main)> hash[‘key‘]=> "value"[47] pry(main)> hash[‘key‘]=> "value"[49] pry(main)> app=> #<RecommendApp _id: 539e995277616e7f74000000, created_at: 2014-06-16 07:14:26 UTC, updated_at: 2014-06-16 07:14:26 UTC, type: 1, position: 0, app_id: BSON::ObjectId(‘53970af477616e1878d40100‘)> [50] pry(main)> app.position=> 0[51] pry(main)> app.read_attribute :position=> 0[52] pry(main)> app.type=> 1[53] pry(main)> app.type_human
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。