I want to create hash with years to send it to form
How to create {2011 => 2011, 2010 => 2010 ... 1990 => 1990}
I tried like @years = [2011..1990].each { |y| @year.push(y => y) }
How to write this correct?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is your answer forwards:
Hash[(1990..2011).map{|y| [y,y]}]and backwards:
Hash[(1990..2011).map{|y| [y,y]}.reverse]