I don't recall if String.split is still in the PowerPack, but you can always use System.String.Split:

[link:msdn.microsoft.com]

instead.

As for intellisense in the editor:

- in a .fsx (script) file, the references from "#r"-ed assemblies will be used to populate intellisense

- in a .fs file in a project, the project references will be used ('add reference')

By on 4/19/2010 2:08 PM ()

I don't recall if String.split is still in the PowerPack, but you can always use System.String.Split:

Well, after some more work, I found that String.split is still in PowerPack.Compatibility for OCaml-related reasons (I assume) and I can make it work that way.

However, that doesn't feel quite like the "right" way to go about this. I tried using System.String.Split, but am told by the interpreter/compiler that "error FS0492: Split is not a static method" Am I just missing something very basic? I tried running the code on an instantiated object so that it wouldn't need to call a static method, but had little success. The MSDN page didn't have any specific F# examples, so I am wondering if

I am just doing something boneheaded and not seeing it while I tinker.

As for intellisense in the editor:

- in a .fsx (script) file, the references from "#r"-ed assemblies

will be used to populate intellisense

- in a .fs file in a project, the project references will be used

('add reference')

Ahh, good to know, thanks!

By on 4/19/2010 2:37 PM ()

Thanks, this did it.

Referencing PowerPack.dll alone didn't remedy the issue.

By on 4/22/2010 8:33 PM ()

Ah, oops, it's an instance method and I didn't notice. This works:

1
2
3
4
5
6
7
8
 

let strings = ["hello world"; "foo bar baz"; "Brian"]
let result = 
    strings
    |> Seq.map (fun s -> s.Split([|' '|], System.StringSplitOptions.RemoveEmptyEntries))
printfn "%A" result 
By on 4/19/2010 2:54 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper