{"id":660,"date":"2020-03-25T19:23:00","date_gmt":"2020-03-26T01:23:00","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=660"},"modified":"2020-03-17T19:42:02","modified_gmt":"2020-03-18T01:42:02","slug":"this-one-might-surprise-you","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2020\/03\/25\/this-one-might-surprise-you\/","title":{"rendered":"This one might surprise you"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Lets start with the code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dim v1 As Variant = Nil\nDim v2 As Variant = 12\n\nIf v1 &lt; v2 Then\n  Break\nElseif v2 &lt; v1 Then\n  Break\nEnd If\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Which break statement would YOU expect to be hit ? I will say that the one that does get hit here is NOT what I expected at all.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you compare variants they convert to a common type. Not sure that I know what the common type that would be used is here. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It doesnt appear to be any of the numeric types.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And the comparison doesn&#8217;t seem to be relying on the hash value of a variant.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you add in code to explicitly convert each variant to some other type (Uint64, int64, Object, String, etc) you see that those all have a nil variant being treated as if its 0 and the non-nil variant as if they are the numeric value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lets start with the code Which break statement would YOU expect to be hit ? I will say that the one that does get hit here is NOT what I expected at all. When you compare variants they convert to a common type. Not sure that I know what the common type that would be &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2020\/03\/25\/this-one-might-surprise-you\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;This one might surprise you&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-660","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=660"}],"version-history":[{"count":1,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/660\/revisions"}],"predecessor-version":[{"id":661,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/660\/revisions\/661"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}