0.0
No release in over 3 years
Low commit activity in last 3 years
A gemified version of the Symbol.find(str) method
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Symbol Lookup Gem

Gem Version Contributor Covenant

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)

Contributing

We require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.

Contributor Code of Conduct

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/

Licence

This project is licensed under the ISC licence. See LICENSE for details