ruby - Getting date value from an array hash -
i have hash looks like
tagarray = { :"2014date"=>["11/22/2014"], :"2015date"=>["03/21/2015"] }
since know given key, there 1 element in array of 'values', how can value not array?
value = tagarray[:"2015date"] => value = ["04/12/2015"]
you can index array , date like
value = value.fetch(0).to_s => value = "04/12/2015"
however looking more elegant way of doing it.
note: using ruby 2.2, need 'strp' date first change mm/dd/yyyy format end goal.
this bit simpler:
value = tagarray[:"2015date"].last => value = "03/21/2015"
Comments
Post a Comment