Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby hash default proc

layers = Hash.new do |layers, layer_name|
  layers[layer_name] = Hash.new(&layers.default_proc)
end

layers[:layer_1][:layer_2][:layer_3] = 'a secret'

layers # => { layer_1: { layer_2: { layers_3: 'a secret' } } }
Comment

PREVIOUS NEXT
Code Example
Ruby :: common functions in rails 
Ruby :: ruby create object with attributes 
Ruby :: rails convert euro to dollar 
Ruby :: Ruby exclude from slice 
Ruby :: rails db:drop not working 
Ruby :: how to overwrite last line of console in ubuntu rails 
Ruby :: rails partial check if local exists 
Ruby :: capybara click with offset 
Ruby :: rails c add timings 
Ruby :: ruby timeout 
Ruby :: does destroy retrurn in ruby 
Ruby :: division in ruby 
R :: r delete all variables 
R :: check type of column in r 
R :: r list append 
R :: extract r squared from lm in r 
R :: how to eliminate duplicates in a column in r 
R :: diff days R lubridate 
R :: count word in a string r 
R :: copy a dataframe in r 
R :: R remove commas 
R :: R squared regression in r with ggplot 
R :: boucle sur r 
R :: r get date from year and day 
R :: 3d scatter plot in r 
R :: point estimates and confidence intervals in r 
R :: how to increment dates inside a for loop in r 
R :: rstudio refactor hotkey 
R :: predict y given model in r 
Rust :: rustlang error: linker `link.exe` not found 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =