enr*_*cis 5

为了理解它,我们可以检查ruby源代码.该类的源代码hash可以在这里找到.

该方法[]=在第4017行定义为:

rb_define_method(rb_cHash,"[]=", rb_hash_aset, 2);
Run Code Online (Sandbox Code Playgroud)

该方法store在第4018行定义为:

rb_define_method(rb_cHash,"store", rb_hash_aset, 2);
Run Code Online (Sandbox Code Playgroud)

如您所见,它们都指向C函数rb_hash_aset,这意味着该方法store只是该方法的别名[]=.

  • 您可以比较Ruby中的方法:`Hash.instance_method(:store)== Hash.instance_method(:[] =)#=> true` (2认同)