1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ruby has_key? vs key?

Last updated at Posted at 2016-06-13

has_key?已经弃用 请使用key?

vagrant@precise64:~/data$ pry
[1] pry(main)> {a: 1}.key?(:a)
=> true
[2] pry(main)> {a: 1}.key?(:b)
=> false
[3] pry(main)> {a: 1,b: {c: 1}}.key?(:b)
=> true
[4] pry(main)> {a: 1,b: {c: 1}}.key?(:c)
=> false
[5] pry(main)> {a: 1,b: {c: 1}}.has_key?(:c)
=> false
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?