From 68fb2bdfdee6db7739bc36a0bcbf3a2251a17ab6 Mon Sep 17 00:00:00 2001 From: dcope-rbx <91100513+dcope-rbx@users.noreply.github.com> Date: Wed, 10 Nov 2021 11:53:43 -0800 Subject: [PATCH] Addressed typecasting documentation feedback (#192) --- docs/_pages/typecheck.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/_pages/typecheck.md b/docs/_pages/typecheck.md index fcc14e0..58e66bb 100644 --- a/docs/_pages/typecheck.md +++ b/docs/_pages/typecheck.md @@ -368,11 +368,11 @@ local myTable = {names = {} :: {string}} table.insert(myTable.names, 42) -- not ok, invalid 'number' to 'string' conversion ``` -A typecast itself is also type checked to ensure the conversion specified is a valid one: +A typecast itself is also type checked to ensure the conversion is made to a subtype of the expression's type or `any`: ```lua -local number = 1 -local value = number :: any -- ok, 'number' is a subtype of 'any' -local flag = number :: boolean -- not ok, invalid 'number' to 'boolean' conversion +local numericValue = 1 +local value = numericValue :: any -- ok, all expressions may be cast to 'any' +local flag = numericValue :: boolean -- not ok, invalid 'number' to 'boolean' conversion ``` ## Roblox types