Rubytastic
Rubytastic

Reputation: 15491

rails assign 10.seconds to a named variable and do calculations?

How would one create a named variable, assign seconds to it, and use it for doing calculations?

start_sec = 10.seconds
end_sec = 20.seconds 

start_sec + end_sec

does not return correct values

Upvotes: 0

Views: 104

Answers (1)

MurifoX
MurifoX

Reputation: 15089

Ugly solution:

start_sec = eval("10.seconds")
end_sec = eval("20.seconds")
start_sec + end_sec

Not sure if you mean this.

Upvotes: 1

Related Questions