Skip to main content Svelte Highlight v7.21.1

Luau language preview

1. Exported types

export type and typed tables
horizon-dark
export type Point = { x: number, y: number }

local origin: Point = { x = 0, y = 0 }
atom-one-dark
export type Point = { x: number, y: number }

local origin: Point = { x = 0, y = 0 }
github-dark
export type Point = { x: number, y: number }

local origin: Point = { x = 0, y = 0 }
dracula
export type Point = { x: number, y: number }

local origin: Point = { x = 0, y = 0 }
nord
export type Point = { x: number, y: number }

local origin: Point = { x = 0, y = 0 }
github
export type Point = { x: number, y: number }

local origin: Point = { x = 0, y = 0 }

2. Typed function

parameter annotations and :: type assertions
horizon-dark
local function add(a: number, b: number): number
  return (a + b) :: number
end
atom-one-dark
local function add(a: number, b: number): number
  return (a + b) :: number
end
github-dark
local function add(a: number, b: number): number
  return (a + b) :: number
end
dracula
local function add(a: number, b: number): number
  return (a + b) :: number
end
nord
local function add(a: number, b: number): number
  return (a + b) :: number
end
github
local function add(a: number, b: number): number
  return (a + b) :: number
end

3. continue in a loop

Luau's continue keyword, not in Lua 5.1
horizon-dark
-- skip zeros
for i, value in ipairs(items) do
  if value == 0 then
    continue
  end
  print(value)
end
atom-one-dark
-- skip zeros
for i, value in ipairs(items) do
  if value == 0 then
    continue
  end
  print(value)
end
github-dark
-- skip zeros
for i, value in ipairs(items) do
  if value == 0 then
    continue
  end
  print(value)
end
dracula
-- skip zeros
for i, value in ipairs(items) do
  if value == 0 then
    continue
  end
  print(value)
end
nord
-- skip zeros
for i, value in ipairs(items) do
  if value == 0 then
    continue
  end
  print(value)
end
github
-- skip zeros
for i, value in ipairs(items) do
  if value == 0 then
    continue
  end
  print(value)
end