RosettaCodeData/Task/Assertions/Julia/assertions.julia

12 lines
401 B
Text
Raw Permalink Normal View History

2020-02-17 23:21:07 -08:00
const x = 5
2018-06-22 20:57:24 +00:00
# @assert macro checks the supplied conditional expression, with the expression
# returned in the failed-assertion message
@assert x == 42
2020-02-17 23:21:07 -08:00
# ERROR: LoadError: AssertionError: x == 42
2018-06-22 20:57:24 +00:00
# Julia also has type assertions of the form, x::Type which can be appended to
# variable for type-checking at any point
x::String
2020-02-17 23:21:07 -08:00
# ERROR: LoadError: TypeError: in typeassert, expected String, got Int64