Project

General

Profile

« Previous | Next » 

Revision 0097c7f3

Added by tenderlovemaking (Aaron Patterson) over 2 years ago

[ruby/fiddle] Add sym_defined? methods to test if a symbol is defined (https://github.com/ruby/fiddle/pull/108)

I would like to check if a symbol is defined before trying to access it.
Some symbols aren't available on all platforms, so instead of raising an
exception, I want to check if it's defined first.

Today we have to do:

begin
  addr = Fiddle::Handle.sym("something")
  # do something
rescue Fiddle::DLError
end

I want to write this:

if Fiddle::Handle.sym_defined?("something")
  addr = Fiddle::Handle.sym("something")
  # do something
end

https://github.com/ruby/fiddle/commit/9d3371de13

Co-authored-by: Sutou Kouhei