commit
506b9ce468
|
|
@ -1,20 +0,0 @@
|
|||
import math
|
||||
|
||||
const pi = math.pi
|
||||
|
||||
pub fn main()
|
||||
{
|
||||
|
||||
// Por padrão os valores são criados como imutável
|
||||
immutable := pi
|
||||
println('${immutable}')
|
||||
|
||||
// Para se tornar variável basta inserir a palavra reservada 'mut'
|
||||
mut mutable := 23.2
|
||||
print('${mutable}\n')
|
||||
|
||||
mutable = pi
|
||||
|
||||
print('${mutable}\n')
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
const min_i8 := i8(-128)
|
||||
const max_i8 := i8(127)
|
||||
|
||||
const min_i16 := i16(-32768)
|
||||
const max_i16 := i16(32767)
|
||||
|
||||
const min_i32 := i32(-2147483648)
|
||||
const max_i32 := i32(2147483647)
|
||||
|
||||
const min_i64 := i64(-9223372036854775807 - 1)
|
||||
const max_i64 := i64(9223372036854775807)
|
||||
|
||||
const mix_u8 := u8(0)
|
||||
const mix_u16 := u16(0)
|
||||
const mix_u32 := u32(0)
|
||||
const mix_u64 := u64(0)
|
||||
|
||||
const max_u8 := u8(127)
|
||||
const max_u16 := u16(32767)
|
||||
const max_u32 := u32(2147483647)
|
||||
const max_u64 := u64(9223372036854775807)
|
||||
|
||||
|
||||
fn main()
|
||||
{
|
||||
mut integer := int(20)
|
||||
mut flt32 := f32(2)
|
||||
mut flt64 := f64(3)
|
||||
|
||||
println(flt32)
|
||||
println(flt64)
|
||||
println(integer)
|
||||
|
||||
println(min_i8)
|
||||
println(max_i8)
|
||||
|
||||
println(min_i16)
|
||||
println(max_i16)
|
||||
|
||||
println(min_i32)
|
||||
println(max_i32)
|
||||
|
||||
println(min_i64)
|
||||
println(max_i64)
|
||||
|
||||
println(min_u8)
|
||||
println(max_u8)
|
||||
|
||||
println(min_u16)
|
||||
println(max_u16)
|
||||
|
||||
println(min_u32)
|
||||
println(max_u32)
|
||||
|
||||
println(min_u64)
|
||||
println(max_u64)
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import math
|
||||
|
||||
const pi = math.pi
|
||||
|
||||
pub fn main()
|
||||
{
|
||||
|
||||
// Por padrão os valores são criados como imutável
|
||||
immutable := pi
|
||||
println('${immutable}')
|
||||
|
||||
// Para se tornar variável basta inserir a palavra reservada 'mut'
|
||||
mut mutable := 23.2
|
||||
print('${mutable}\n')
|
||||
|
||||
mutable = pi
|
||||
|
||||
print('${mutable}\n')
|
||||
|
||||
a, c, d := 3, 2, 5
|
||||
|
||||
mut i, mut j := 'Hi', 'Hello'
|
||||
|
||||
println("${a} ${c} ${d}")
|
||||
println("${i} ${j}")
|
||||
|
||||
mut greet := 'Here'
|
||||
|
||||
greet = greet + ' there and Everywhere'
|
||||
|
||||
println("${greet}")
|
||||
|
||||
greet += ' Hope yout have a great day!'
|
||||
|
||||
println("${greet}")
|
||||
|
||||
mut is_false := false
|
||||
mut is_true := true
|
||||
|
||||
println(is_false)
|
||||
println(is_true)
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
multiply accepts two integers arguments namely x and y
|
||||
|
||||
It then performs multiplication of input arguments and
|
||||
return the product which is again a type of integer as
|
||||
specified in the function signature
|
||||
|
||||
x is an input argumento accepts values of type of int
|
||||
y is an input argument accepts values of type of int
|
||||
|
||||
multiply functions returns the result of type int which
|
||||
is a multiplication of input arguments x and y
|
||||
|
||||
*/
|
||||
fn multiply(x int, y int) int
|
||||
{
|
||||
return x * y
|
||||
}
|
||||
|
||||
// main function callable by operating system
|
||||
pub fn main()
|
||||
{
|
||||
println("Hello world")
|
||||
|
||||
println(multiply(2,4))
|
||||
}
|
||||
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
|
||||
|
||||
pub fn main() {
|
||||
println('oi')
|
||||
}
|
||||
Loading…
Reference in New Issue