>> a = "abc" #=> "abc" >> b = a + "" #=> "abc" ?> a == b #=> true >> a.object_id #=> 70255156346640 >> b.object_id #=> 70255156340640
case some_object
when /a regex/
# The regex matches
when String
# some_object is kind of String
when 2..4
# some_object is in the range 2..4
when lambda {|x| some_crazy_custom_predicate }
# the lambda returned true
end
if /a regex/ === some_object
# The regex matches
elsif String === some_object
# some_object is kind of object
elsif (2..4) === some_object
# some_object is in the range 2..4
elsif lambda {|x| some_crazy_custom_predicate } === some_object
# the lambda returned true
end
1 == 1.0 #=> true 1.eql? 1.0 #=> false
[1] pry(main)> hash = Hash.new
#=> {}
[2] pry(main)> hash[2] = "a"
#=> "a"
[3] pry(main)> hash[2.0] = "b"
#=> "b"
[4] pry(main)> hash[2]
#=> "a"
[5] pry(main)> hash[2.0]
#=> "b"
[6] pry(main)> hash[2.00] = "c"
#=> "c"
[7] pry(main)> hash[2.0]
#=> "c"
q = User.first User Load (40.4ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 #=> #<User id: 1, email: "ryan@wongyouth.com"> q2 = User.first User Load (0.4ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 #=> #<User id: 1, email: "ryan@wongyouth.com"> q.equal? q2 #=> false
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有