Cheddar Documentation
  • Introduction
  • Syntax
  • Literals
    • Comment
    • String
    • Number
    • Array
    • Boolean
  • Mathematics
    • Addition
    • Subtraction
    • Multiplication
    • Division
    • Exponentiation
    • Remainder
    • Negation
    • Sign
    • Root
    • Bitwise AND
    • Bitwise OR
    • Bitwise XOR
    • Bitwise NOT
    • Bitwise Left Shift
    • Bitwise Right Shift
  • Variables
  • Functions
    • Defining
      • Lambda
      • Functionized Operators
      • Functionized Properties
    • Operations
      • Functional Bonding
      • Functional Composition
  • Default Operators
    • What Is
    • Instance-of
    • Actually Is
  • Control Flow
    • Conditional
    • Loops
      • For Loops
      • While Loops
  • Standard Library
    • String
      • Bytes
      • Count
      • Length
      • Match
      • Slice
      • Tail
      • Chars
      • Head
      • Lines
      • Ord
      • Split
      • Test
      • Chunk
      • Index
      • Lower
      • Reverse
      • Substitute
      • Upper
  • Developing
    • Structure
    • Primitive Objects
      • Scope
      • Class
      • Variable
      • Namespace
    • Getting Started
    • API
      • Primitives
        • string
        • number
        • array
        • bool
        • func
        • nil
Powered by GitBook
On this page
  • Basic Syntax
  • Using special characters
  • Using formatting

Was this helpful?

  1. Literals

String

PreviousCommentNextNumber

Last updated 4 years ago

Was this helpful?

Strings are traditionally a sequence of characters, but you can think of them as "text". Cheddar's strings are like 's strings.

Basic Syntax

Strings in Cheddar are delimited by double quotes or single quotes. Additionally, Cheddar supports literal newlines within Strings.

"Hello, World!" // Both of these are
'Hello, World!' // exactly the same

Whichever quote you use is your choice and varies based on your personal preference. For the rest of this documentation, double quotes will be used.

Using special characters

Cheddar is, again, like the C language in respect to escaping. You can use a backslash before a character to insert it's literal form rather than it to have a special meaning.

"This is a double quote: \"."
'This is a single quote: \'.'
"This is a blackslash: \\"

Using formatting

"String formatting" is a way to insert the result of an expression directly into a string. Using #{ ... } you can "format" a string.

 "2+2=#{2+2}" # evaluates 2+2 and returns 4
 "2+2=4"      # Has the same value as the above

Backslashes also work to escape formatting:

"2+2=\#{2+2}" # Does NOT evaluate 2+2 or the format

This evaluates to: 2+2=#{2+2}

Ruby