Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby zip rows and columns

columns = [ "Name", "city", "employed"]
 
rows = [ 
  [ "Matt",   "Seattle",    true ], 
  [ "Amy",  "Chicago", true], 
  [ "Nice", "Lahore",     false ]
]

rows.map{|r| Hash[ columns.zip(r) ] }
# [
#	{"Name"=>"Matt", "city"=>"Seattle", "employed"=>true}, 
#	{"Name"=>"Amy", "city"=>"Chicago", "employed"=>true}, 
#	{"Name"=>"Nice", "city"=>"Lahore", "employed"=>false}
# ]
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby regex replace capture group 
Ruby :: devise trackable not working for authentication 
Ruby :: ruby hash default proc 
Ruby :: ruby create object with attributes 
Ruby :: refactor duplicate tests rspec 
Ruby :: class inheriting multiple modules in ruby 
Ruby :: after_create for STI rails 
Ruby :: rails has_many through source 1 
Ruby :: sequel not ruby 
Ruby :: add key and value to the beginning of a hash ruby 
Ruby :: compiler version at runtime 
Ruby :: get specific key value from array of hashes in ruby 
Ruby :: rails revert migration 
R :: R string ascii accents 
R :: R p value star 
R :: composite score in r 
R :: merge multiple datatable in r 
R :: remove all empty strings from R 
R :: import excel into r 
R :: how to itterate through a character in r 
R :: ggplot2 graph in r 
R :: R darekn color 
R :: r remove insignificant coefficient in output 
R :: stat_poly_eq position 
R :: r remove column by index 
R :: ggplot glm 
R :: eleminating a char in of a list in r 
R :: change to posixct in r 
R :: convert ratio to numeric in r 
R :: how to combine multiple time series in r 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =