examples: fix optional in string interpolation and format error (#14079)
parent
e16ce3af88
commit
a318a2e09e
|
@ -8,8 +8,8 @@ fn main() {
|
||||||
conn.close() or {}
|
conn.close() or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
println(' peer: $conn.peer_addr()')
|
println(' peer: ${conn.peer_addr() ?}')
|
||||||
println('local: $conn.addr()')
|
println('local: ${conn.addr() ?}')
|
||||||
|
|
||||||
// Simple http HEAD request for a file
|
// Simple http HEAD request for a file
|
||||||
conn.write_string('HEAD /index.html HTTP/1.0\r\n\r\n') ?
|
conn.write_string('HEAD /index.html HTTP/1.0\r\n\r\n') ?
|
||||||
|
|
|
@ -2,6 +2,6 @@ import rand
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
for _ in 0 .. 10 {
|
for _ in 0 .. 10 {
|
||||||
println('${rand.intn(255)}.${rand.intn(255)}.${rand.intn(255)}.${rand.intn(255)}')
|
println('${rand.intn(255) ?}.${rand.intn(255) ?}.${rand.intn(255) ?}.${rand.intn(255) ?}')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,8 @@ pub fn (lit &StringInterLiteral) get_fspec_braces(i int) (string, bool) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
CallExpr {
|
CallExpr {
|
||||||
if sub_expr.args.len != 0 || sub_expr.concrete_types.len != 0 {
|
if sub_expr.args.len != 0 || sub_expr.concrete_types.len != 0
|
||||||
|
|| sub_expr.or_block.kind == .propagate || sub_expr.or_block.stmts.len > 0 {
|
||||||
needs_braces = true
|
needs_braces = true
|
||||||
} else if sub_expr.left is CallExpr {
|
} else if sub_expr.left is CallExpr {
|
||||||
sub_expr = sub_expr.left
|
sub_expr = sub_expr.left
|
||||||
|
|
Loading…
Reference in New Issue