简体   繁体   中英

Why am I able to directly use some of the ruby C extension array methods, but not others?

I am using many of the array methods found in array.c of the ruby codebase, but when trying to call

VALUE rIntersection = rb_ary_and(rAry1, rAry2); 

I got this error:

dyld: lazy symbol binding failed: Symbol not found: _rb_ary_and
  Referenced from: ./ext/ev/counters.bundle
  Expected in: flat namespace

In other areas of my code I am using rb_ary_sort_bang, rb_ary_clear, rb_ary_reverse, etc etc. So I'm not sure why rb_ary_and is any different.

Have a look at http://www.ruby-doc.org/doxygen/1.8.4/array_8c-source.html (Line 2666)

There you can see that the method rb_ary_and is declared static . This means that it is only visible inside of array.c .

Untested, but I would assume this would work:

rb_funcall( rAry1, rb_intern("&"), 1, rAry2 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM