nothing

Using Haskell's “Maybe”, type declarations [beginner's question]

故事扮演 提交于 2019-11-28 03:58:30
问题 I've started experimenting with Haskell and have a problem. qqq is a function that should print one string if called with "Nothing" and print other things if called with "Just something". The first attempt seems like working: qqq Nothing = print "There isn't anything to be printed." qqq (Just x) = print "There is something to be printed." >> print x main :: IO () main = qqq (Just 43) But: when I try to make main = qqq (Nothing) it fails ("Ambiguous type variable `a0' in the constraint: (Show

Why can't I check if a 'DateTime' is 'Nothing'?

你。 提交于 2019-11-28 03:53:16
In VB.NET, is there a way to set a DateTime variable to "not set"? And why is it possible to set a DateTime to Nothing , but not possible to check if it is Nothing ? For example: Dim d As DateTime = Nothing Dim boolNotSet As Boolean = d Is Nothing The second statement throws this error: 'Is' operator does not accept operands of type 'Date'. Operands must be reference or nullable types. This is one of the biggest sources of confusion with VB.Net, IMO. Nothing in VB.Net is the equivalent of default(T) in C#: the default value for the given type. For value types, this is essentially the

VBA: Conditional - Is Nothing

偶尔善良 提交于 2019-11-27 23:24:33
问题 There is an If condition in a VBA application as seen below: If Not My_Object Is Nothing Then My_Object.Compute When the code is run in debug mode, I found that the If condition returns a true even when My_Object has "No Variables". Could somebody please explain this? I want My_Object.Compute to be executed only when My_Object exists. 回答1: Based on your comment to Issun: Thanks for the explanation. In my case, The object is declared and created prior to the If condition. So, How do I use If

Nothing = String.Empty (Why are these equal?)

扶醉桌前 提交于 2019-11-27 08:50:58
Why does the first if statement evaluate to true? I know if I use "is" instead of "=" then it won't evaluate to true. If I replace String.Empty with "Foo" it doesn't evaluate to true. Both String.Empty and "Foo" have the same type of String, so why does one evaluate to true and the other doesn't? //this evaluates to true If Nothing = String.Empty Then End If //this evaluates to false If Nothing = "Foo" Then End If Nothing in VB.net is the default value for a type. The language spec says in section 2.4.7: Nothing is a special literal; it does not have a type and is convertible to all types in

VB.NET – IsNothing versus Is Nothing

落爺英雄遲暮 提交于 2019-11-27 06:46:28
Does anyone here use VB.NET and have a strong preference for or against using IsNothing as opposed to Is Nothing (for example, If IsNothing(anObject) or If anObject Is Nothing... )? If so, why? EDIT: If you think they're both equally acceptable, do you think it's best to pick one and stick with it, or is it OK to mix them? If you take a look at the MSIL as it's being executed you'll see that it doesn't compile down to the exact same code. When you use IsNothing() it actually makes a call to that method as opposed to just evaluating the expression. The reason I would tend to lean towards using

Why can't I check if a 'DateTime' is 'Nothing'?

喜欢而已 提交于 2019-11-27 05:13:47
问题 In VB.NET, is there a way to set a DateTime variable to "not set"? And why is it possible to set a DateTime to Nothing , but not possible to check if it is Nothing ? For example: Dim d As DateTime = Nothing Dim boolNotSet As Boolean = d Is Nothing The second statement throws this error: 'Is' operator does not accept operands of type 'Date'. Operands must be reference or nullable types. 回答1: This is one of the biggest sources of confusion with VB.Net, IMO. Nothing in VB.Net is the equivalent

Error checking for NULL in VBScript

若如初见. 提交于 2019-11-26 20:49:12
问题 I have the following VBScript in a Classic ASP page: function getMagicLink(fromWhere, provider) dim url url = "magic.asp?fromwhere=" & fromWhere If Not provider is Nothing Then ' Error occurs here url = url & "&provider=" & provider End if getMagicLink = "<a target='_blank' href='" & url & "'>" & number & "</a>" end function I keep getting an "Object Required" error messager on the line that says If Not provider Is Nothing Then . Either the value is NULL, or it's not NULL, so why am I getting

Nothing = String.Empty (Why are these equal?)

[亡魂溺海] 提交于 2019-11-26 17:46:50
问题 Why does the first if statement evaluate to true? I know if I use "is" instead of "=" then it won't evaluate to true. If I replace String.Empty with "Foo" it doesn't evaluate to true. Both String.Empty and "Foo" have the same type of String, so why does one evaluate to true and the other doesn't? //this evaluates to true If Nothing = String.Empty Then End If //this evaluates to false If Nothing = "Foo" Then End If 回答1: Nothing in VB.net is the default value for a type. The language spec says

IsNothing versus Is Nothing

我与影子孤独终老i 提交于 2019-11-26 12:09:52
问题 Does anyone here use VB.NET and have a strong preference for or against using IsNothing as opposed to Is Nothing (for example, If IsNothing(anObject) or If anObject Is Nothing... )? If so, why? EDIT: If you think they\'re both equally acceptable, do you think it\'s best to pick one and stick with it, or is it OK to mix them? 回答1: If you take a look at the MSIL as it's being executed you'll see that it doesn't compile down to the exact same code. When you use IsNothing() it actually makes a