Module: SuggestDbIndices::Clojure
- Defined in:
- lib/suggest_db_indices/clojure.rb
Overview
Learnings from Clojure for make great benefit ruby
Class Method Summary collapse
-
.get_in(enumerable, keys, default = nil) ⇒ Object
Get multiple keys, e.g., h = => {:a => 5} Clojure.get_in(h, [:b, :a]) # => 5 Clojure.get_in(h, [:b, :a, :c]) # => nil Clojure.get_in(h, [:b, :a, :c], 1) # => 1.
Class Method Details
.get_in(enumerable, keys, default = nil) ⇒ Object
Get multiple keys, e.g., h = => {:a => 5} Clojure.get_in(h, [:b, :a]) # => 5 Clojure.get_in(h, [:b, :a, :c]) # => nil Clojure.get_in(h, [:b, :a, :c], 1) # => 1
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/suggest_db_indices/clojure.rb', line 10 def get_in enumerable, keys, default = nil current = enumerable while key = keys.shift unless current.is_a? Enumerable current = nil break end current = current[key] end current || default end |