Skip to content

Commit

Permalink
merge lesson2,3 in chapter1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoorkin committed Dec 16, 2024
1 parent ad221bb commit 1d2999e
Show file tree
Hide file tree
Showing 22 changed files with 17 additions and 18 deletions.
8 changes: 8 additions & 0 deletions moonbit-tour/tour/chapter1_basics/lesson1_variable/index.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ fn main {
let a : Int = 10
let b = 20
println(a + b)

let mut c = 10
c = c + 1
println(c)

let d = 20
// d = d + 1
println(d)
}
3 changes: 3 additions & 0 deletions moonbit-tour/tour/chapter1_basics/lesson1_variable/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ The `let` keyword used to define a variable.
The type of the variable can be annotated by using a colon followed by the type.
It is optional, if not provided the type will be inferred from the value.

Variables are immutable by default in MoonBit. You can add an extra `mut`
keyword to make them mutable at the local level.

If you uncomment the `d = d + 1`, you will get an error.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ fn main {
let oct = 0o777
let bin = 0b1001

println(1 + 2)
println(1 - 2)
println(1 * 2)
println(5 / 2)
println(10 % 3)

let num1 : Double = 3.14
let num2 : Float = 3.14
}
Expand Down

0 comments on commit 1d2999e

Please sign in to comment.