I am wondering if there is an elegant way to create variables using a loop in ruby?
Say I want to put this in some sort of loop
def workhours
@monday = blah
@tuesday = brah
@wednesday = bro
@thursday = blap
@friday = blagh
end
What I want to be able to do
def workhour_ideally
days = [ "monday", "tuesday", "wednesday", "thursday", "friday" ]
days.each do |smack|
@"smack" = whatever
end
end
Is this possible with ruby?