-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
sym_defined?
methods to test if a symbol is defined (#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: ```ruby begin addr = Fiddle::Handle.sym("something") # do something rescue Fiddle::DLError end ``` I want to write this: ```ruby if Fiddle::Handle.sym_defined?("something") addr = Fiddle::Handle.sym("something") # do something end ``` Co-authored-by: Sutou Kouhei <kou@clear-code.com>
- Loading branch information
1 parent
49fa723
commit 9d3371d
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters