Have this code:
before = Time.now
sleep(Random.rand())
after = Time.now
STDOUT.puts("Before - Milliseconds: <(before.milliseconds)>")
STDOUT.puts("After - Milliseconds: <(after.milliseconds)>" )
And see it run:
$ myst test.mt
Uncaught Exception: No variable or method `milliseconds` for 2018-06-08 16:52:57:Time
The error in this program is that the method aimed for is Time#millisecond, as there exists no Time#milliseconds (with a trailing s).
The error message makes it clear that there is no variable or method milliseconds, – but for 2018-06-08 16:52:57:Time? At least to me, it seems very unlikely that 2018-06-08 16:52:57:Time would have any variables or methods at all. My point is that I believe using to_s in this situation can be very unclear.
Something like this would be good:
Uncaught Exception: No variable or method `milliseconds` for `before` test.mt:4
Have this code:
And see it run:
The error in this program is that the method aimed for is
Time#millisecond, as there exists noTime#milliseconds(with a trailings).The error message makes it clear that there is no variable or method
milliseconds, – but for2018-06-08 16:52:57:Time? At least to me, it seems very unlikely that2018-06-08 16:52:57:Timewould have any variables or methods at all. My point is that I believe usingto_sin this situation can be very unclear.Something like this would be good: