没有合适的资源?快使用搜索试试~ 我知道了~
首页Nim in Action--2018
Nim is a multi-paradigm language that offers powerful customization options with the ability to compile to everything from C to JavaScript. In Nim in Action you’ll learn how Nim compares to other languages in style and performance, master its structure and syntax, and discover unique features
资源详情
资源评论
资源推荐

Nim Reference
Common constructs
const x = 5 Compile-time constant
let y = “Hello” Immutable binding
var z = [1, 2, 3] Mutable variable
proc name(param: int): ReturnType = body
method name(param: float): ReturnType = body
iterator items(list: seq[int]): int = body
template name(param: typed) = body
macro name(param: string): untyped = body
if x > 5:
body
elif y == "Hello":
body
else:
body
case x
of 5:
body
of 1, 2, 3: body
of 6..30:
body
for item in list:
body
for i in 0..<len(list):
body
while x == 5:
if y.len > 0:
break
else:
continue
try:
raise err
except Exception as exc:
echo(exc.msg)
finally: discard
Input/Output
echo(x, 42, "text") readFile("file.txt")
stdout.write("text") writeFile("file.txt", "contents")
stderr.write("error") open("file.txt", fmAppend)
stdin.readLine()
Type definitions
type
MyType = object
field: int
type
Colors = enum
Red, Green,
Blue, Purple
type
MyRef = ref object
field*: string
Licensed to <null>
www.allitebooks.com
剩余323页未读,继续阅读
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1