let retVal =
if reader.Read() then
(reader.GetString(0), getBytesData reader 1, reader.GetDateTime(2))
else
null
F# 不允许不退还
www.un.org/Depts/DGACM/index_spanish.htm 怎样才能将回报作为主食或无物?
let retVal =
if reader.Read() then
(reader.GetString(0), getBytesData reader 1, reader.GetDateTime(2))
else
null
F# 不允许不退还
www.un.org/Depts/DGACM/index_spanish.htm 怎样才能将回报作为主食或无物?
在 Yin的回答中增加一些额外信息,情况见null
。 F#语言的价值如下:
F# category, such as tuples (e. int * int
), which is actual t no have null
as a valid Value, so You can not use null
in this case (other such forms are function Value e.g. int -> int
, list and most of the F# Library range)
类型。 NET框架可以有<代码>null数值,因此,例如,可以写:
let (rnd:Random) = null
这只字体F#风格,但允许。
如果你界定自己的F#类型,它就自动允许你使用<代码>null<>/code>作为这种类型的有效价值(按照在F#中尽量减少使用<代码>null这一目标)。 然而,你可以明确允许:
[<AllowNullLiteral>]
type MyType = ...
为了进一步澄清,我抄录了我的回答:。 你们怎样才能把一只零件从一只到一杯? 作为这一问题的重复而关闭:
如果你需要与C#进行联系,请使用<代码>Unchecked.Defaultof。 同样:
let retVal =
if reader.Read() then
(reader.GetString(0), getBytesData reader 1, reader.GetDateTime(2))
else
Unchecked.Defaultof<_>
然而,F#中强烈反对使用无效价值,如果互操作性不是你的主要关切,则使用一种选择更自然:
let retVal =
if reader.Read() then
Some (reader.GetString(0), getBytesData reader 1, reader.GetDateTime(2))
else
None
I have a number of events that happen in a game. I want to control the time and order at which these events occur. For example: Event 1: Show some text on screen for N frames & play a sound ...
Is there an easy way to create Silverlight 3 applications with F# (October CTP)? I have seen the F# for Silverlight, but that only works with the May CTP. I am using Visual Studio Integrated Shell ...
In F# I want to transform a list of chars into a string. Consider the following code: let lChars = [ a ; b ; c ] If I simply do lChars.ToString, I get "[ a ; b ; c ]". I m trying to get "abc". I ...
I m reading a file(a flash swf) from .Net 3.5 that has a header which states whether the body of the file/Stream is compressed or not. However, I m having problems-after I rewrap the basic File ...
Let s say I have a binary tree data structure defined as follows type a tree = | Node of a tree * a * a tree | Nil I have an instance of a tree as follows: let x = Node (Node (...
(Background: I ve been thinking about doing a presentation on F# and functional programming. From experience, I think that the wow factor of pattern matching and type inference is not necessarily ...
I recently began to read some F# related literature, speaking of "Real World Functional Programming" and "Expert F#" e. g.. At the beginning it s easy, because I have some background in Haskell, and ...
As part of a project I have assigned myself as a way of improving my knowledge of F# and functional programming in general, I am attempting to write a string pattern-matching algorithm from scratch ...