Fsharp: At Sign @ String (verbatim)

By Xah Lee. Date: . Last updated: .

At sign @ string

Everything is verbatim, except, two adjacent QUOTATION MARK means a single QUOTATION MARK.

Syntax

Syntax is an “at sign” in front of quote. e.g.

@"abc"

// to include a quote, double it
let xx = @"said: ""yes""."
printfn "%s" xx
// said: "yes".

Example. multiple lines

// can be multiple lines
let xx = @"aa
bb"
printfn "%s" xx
(*
aa
bb
 *)

Example. backslash has no special meaning

// backslash has no special meaning

let xx = @"aa\nbb"
printfn "%s" xx
// aa\nbb

let zz = @"aa\
   bb"
printfn "%s" zz

(*
aa\
   bb
 *)

Two adjacent quotation marks means single

// two QUOTATION MARKs means single
let zz = @"he said: ""yes""."
printfn "%s" zz
// he said: "yes".

On triple quoted string

can also be in front of triple quote @"""abc""" but no effect because triple quote is already verbatim.

// at sign can be placed in front of triple quoted string
let xx = @"""abc"""
printfn "%s" xx
// "abc"

// two QUOTATION MARKs means single
let zz = @"""ab""cd"""
printfn "%s" zz
// "ab"cd"