mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-04-19 19:34:00 +01:00
Fixed rawget example
This commit is contained in:
parent
3babf9bfab
commit
f2685c315b
1 changed files with 4 additions and 4 deletions
|
@ -25,12 +25,12 @@ end
|
||||||
For instance, the `rawget` type function can be written as:
|
For instance, the `rawget` type function can be written as:
|
||||||
```luau
|
```luau
|
||||||
type function rawget(tbl, prop)
|
type function rawget(tbl, prop)
|
||||||
if typelib.isunion(prop) then
|
if typelib.isunion(tbl) or typelib.isunion(prop) then
|
||||||
print("Warning: union types are not supported!") -- output a warning
|
print("Warning: union types are not supported!") -- outputs a warning
|
||||||
end
|
end
|
||||||
|
|
||||||
if not typelib.istable(tbl) or not (typelib.isstringsingleton(prop) || typelib.isbooleansingleton(prop)) then
|
if not typelib.istable(tbl) then
|
||||||
error("The parameters of rawget type function is wrong!") -- fails to reduce
|
error("First argument is not a table!") -- fails to reduce
|
||||||
end
|
end
|
||||||
|
|
||||||
return tbl:getprops()[prop:getvalue()]
|
return tbl:getprops()[prop:getvalue()]
|
||||||
|
|
Loading…
Add table
Reference in a new issue