Chevron Left Icon
LOLCODE YARNs (Strings)
Lesson 1 of 2
Chevron Right Icon
  1. 1
    LOLCODE allows us to combine, or concatenate, multiple strings together by using the SMOOSH and MKAY keywords. For example, if the code below is executed: BTW Results in “baklavaaaaaaa” VISIBLE S…
  2. 2
    For the case of SMOOSHing together strings and variables, LOLCODE supports a popular shortcut called string interpolation. Interpolation here refers to placing variables within strings in an easi…
  3. 3
    Most programming languages have some way of embedding specialized characters in strings that need to be presented in an unusual way. For example, “newline” characters (often represented by \n) indi…
  4. 4
    Fun fact: Unicode is the standard for how strings are stored and displayed across systems. It’s maintained by the Unicode Consortium, a non-profit organization with responsibilities ranging…
  1. 1
    LOLCODE has 5 basic types of variables: - NOOB: not yet given a type - NUMBR: integers (whole numbers) - NUMBAR: floats (decimal numbers) - YARN: string (text) - TROOF: booleans (WIN and FAIL, equ…
  2. 2
    LOLCODE allows converting a variable to a different types, such as from a NUMBAR (float) to a NUMBR (integer), using the IS NOW A command. It goes on a line between a variable’s name and a new ty…
  3. 3
    LOLCODE also allows converting string types, or YARNs, to the two numeric types. The syntax is the same: given a variable name, follow it with IS NOW A and the numeric type to convert to. Converti…
  4. 4
    Traditional arithmetic operations are supported on numeric types in LOLCODE: BTW Addition SUM OF x AN y BTW Subtraction DIFF OF x AN y BTW Multiplication PRODUKT OF x AN y BTW Division QUOSHUNT…
  5. 5
    Similarly, LOLCODE supports equivalents of the * and / operators: BTW Multiplication PRODUKT OF x AN y BTW Division QUOSHUNT OF x AN y These follow the same rules as adding or subtracting: if e…
  6. 6
    You’ve seen that when dividing two integer numbers that don’t fit evenly, some amount will be left out. That amount, called the remainder, can be directly retrieved by the modulo operation. Mo…
  7. 7
    Some languages use a native Math object for advanced operations on numbers. LOLCODE doesn’t have an advanced mathematics object. Still, it does support two of the more common math functions from o…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo