A gemified version of the Symbol[str] method proposed in https://bugs.ruby-lang.org/issues/7854
call-seq:
Symbol.find str => Symbol or nil
Symbol[str] => Symbol or nil
str.interned? => Symbol or nil
str.to_existing_sym => Symbol or ArgumentError
Returns an extant symbol, which is the .to_sym of str, or
nil if no such symbol exists.
Symbol.find 'Object' #=> :Object
Symbol.find 'none such' #=> nil
Symbol['Object'] #=> :Object
Symbol['none such'] #=> nil
'Object'.interned? #=> :Object
'none such'.interned? #=> nil
'Object'.to_existing_sym #=> :Object
'none such'.to_existing_sym #=> (raises ArgumentError)
We require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.
This repository is subject to a Contributor Code of Conduct adapted from the Contributor Covenant, version 3.0, available at https://www.contributor-covenant.org/version/3/0/
This project is licensed under the ISC licence. See LICENSE for details
Copyright (c) 2013,2014, Matthew Kerwin <matthew@kerwin.net.au> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.