Last active
December 28, 2015 14:59
-
-
Save onionhammer/7518186 to your computer and use it in GitHub Desktop.
Range issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TSomeRange = object | |
hour: range[0..23] | |
var value: string | |
#Works | |
var val6 = TSomeRange(hour: 6) | |
value = $(if val6.hour > 12: val6.hour - 12 else: val6.hour) | |
echo value | |
var val14 = TSomeRange(hour: 14) | |
value = $(if val14.hour > 12: val14.hour - 12 else: val14.hour) | |
echo value | |
#With 12, works | |
var val12 = TSomeRange(hour: 12) | |
if val12.hour > 12: value = $(val12.hour - 12) else: value = $val12.hour | |
echo value | |
#Crashes | |
value = $(if val12.hour > 12: val12.hour - 12 else: val12.hour) | |
echo value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment