x to !
Posted: Thu May 07, 2009 1:27 pm
The expression "x to !" casts a nilable type to its non-nilable type. It's a shorthand form. I'll explain the rest in code snippets:
Also, see the UseNilAndNilableTypes How To
# Consider if x is of type:
Dictionary<of String, int>?
# You could cast like this:
x to Dictionary<of String, int>
# But this is the same thing and easier:
x to !
# And this:
a = b to !
# Means that the local var "a" will be a non-nil type.
# If the cast fails because the expression is nil, then you will get a NonNilCastException
Also, see the UseNilAndNilableTypes How To