+ 5

Declaring time variables:

If I declare a variable (t = Time.new) tm = t.sec and some lines of code later tm2 = t.sec Will tm and tm2 have the same value? or not?

26th Mar 2017, 9:39 AM
MrCoder
MrCoder - avatar
11 odpowiedzi
+ 8
Its yes, because the value of t doesnt change. if you do it like this: t = Time.new tm = t.sec then some lines later t = Time.new tm2 = t.sec theyll have different values because t gets reassigned
26th Mar 2017, 3:47 PM
Supersebi3
Supersebi3 - avatar
+ 7
No
26th Mar 2017, 9:40 AM
Prabhakar Dev
Prabhakar Dev - avatar
+ 7
Please go to my profile and see my code 'a new way of promoting codes'... Pleeeeaaasseee
26th Mar 2017, 9:56 AM
Prabhakar Dev
Prabhakar Dev - avatar
+ 7
@Suoersebi3 Ohh I get it now thank you :D
27th Mar 2017, 7:37 AM
MrCoder
MrCoder - avatar
+ 7
Yup :D
1st Apr 2017, 10:26 AM
MrCoder
MrCoder - avatar
+ 6
Oh alright thanks @Prabhakar Pandey :D
26th Mar 2017, 9:41 AM
MrCoder
MrCoder - avatar
+ 6
@Huan Wang Okay I've seen new method and I'll try to use now, thanks :D
26th Mar 2017, 11:01 AM
MrCoder
MrCoder - avatar
+ 6
@Prabhakar Pandey Okay :D
26th Mar 2017, 11:01 AM
MrCoder
MrCoder - avatar
+ 6
yay best
1st Apr 2017, 10:25 AM
Supersebi3
Supersebi3 - avatar
+ 3
You're welcome. So the answer is obviously yes
26th Mar 2017, 11:38 AM
Steven Wang
Steven Wang - avatar
+ 2
When it comes to yes or no, you can just run the code and see what happens. The new method without arguments is an alias for the now method. So you know the answer...
26th Mar 2017, 10:54 AM
Steven Wang
Steven Wang - avatar