-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax and semantics
EM CONSTRUÇÃO
The variables work with optional typing similar to TypeScript, but with the possibility to use the types available through C# language.
types of scope
You can use 'del' to remove the variable, constants and objects from memory when you want, this is a cool and flexible Python resource that some other languages haven't. It increase your control, but remember that you have garbage collector to help you.
Syntax:
del <variable | constant | object>
Sample:
int number = 10
println(number)
del number
println(number)
# Output
> 10
> The variable 'b' was not declared.
To set a variable value as null in some languages, you can do it using the keyword 'nil' (ruby) or 'none' (python), but it's ugly and not objective, because when you think to set a null value you think in 'null' keyword. So Kymera use the key 'null' like C# to it.
Syntax:
<variable | constant | object> = null
Sample: int number = 42 println(number)
number = null
println(number)
# Output
> 42
> null
To print something on console you can use the 'Console' class methods, that is 'print' and 'println'. This is based on Java and C#. The 'Console' class can be implicit.
- Console.print - Just print a text in your console.
- Console.println - Print a text in your console and break line.
Syntaxe:
Console.print(<value_to_print>)
Console.println(<value_to_print>)
Sample:
Console.print("Hello ")
Console.print("Universe!")
# Output
> Hello Universe!
Console.println("Hello ")
Console.println("Universe!")
# Output
> Hello
> Universe!
or
print("Hello ")
print("Universe!")
# Output
> Hello Universe!
println("Hello ")
println("Universe!")
# Output
> Hello
> Universe!
//
/* */
You can use two ways to declare constants: You can use keyword const
12 The if-else Statement 13 The switch Statement 14 The while Loop 15 The for Loop 16 The do-while Loop 17 break and continue 18 Logical Operators 19 The Conditional Operator 20 Basic Calculator 21 Module 2 Quiz
Introduction to Methods 23 Method Parameters 3 24 Multiple Parameters 2 25 Optional & Named Arguments 2 26 Passing Arguments 3 27 Method Overloading 2 28 Recursion 2 29 Making a Pyramid 1 30 Module 3 Quiz 5 Module 4: Classes & Objects
31 Introduction 3 32 Value & Reference Types 2 33 Class Example 3 34 Encapsulation 3 35 Constructors 2 36 Properties 5 37 Module 4 Quiz 7 Module 5: Arrays & Strings
38 Arrays 4 39 Using Arrays in Loops 3 40 Multidimensional Arrays 2 41 Jagged Arrays 1 42 Array Properties & Methods 2 43 Working with Strings 2 44 Module 5 Quiz 5 Module 6: More On Classes
45 Destructors 2 46 Static Members 4 47 Static Classes 2 48 this & readonly 2 49 Indexers 2 50 Operator Overloading 2 51 Module 6 Quiz 6 Module 7: Inheritance & Polymorphism
52 Inheritance 3 53 Protected Members 2 54 Derived Class Constructor & Destructor 2 55 Polymorphism 4 56 Abstract Classes 2 57 Interfaces 2 58 Nested Classes 1 59 Namespaces 1 60 Module 7 Quiz 7 Module 8: Structs, Enums, Exceptions & Files
61 Structs 2 62 Enums 2 63 Exception Handling 4 64 Working with Files 2 65 Module 8 Quiz 6 Module 9: Generics
66 Generic Methods 2 67 Generic Classes 2 68 Collections 2
Blocos serão por chaves {} da mesma forma que o C/C++, Dart, Go, Java, C# e JS usam, pois o uso de begin e end são desnecessários.
--Variáveis: ---A declaração é opcional assim como no GoLang. a //igual ao var, mas é de forma implícita. var a //simplesmente declara a variável como qualquer tipo smallint a int a float a double a char a string a bool a struct a dic a // a{ 'b' : 1; 'c' : 2} tuple a // a() array a // a[] // a const A enum a *ponteiro **ponteiro_de_ponteiro global int a
--Estruturas de repetição:
for elemento in elementos { //procedimento }
for (int x; x<10; x++) { //procedimento }
while ( x < y ) { //procedimento }
do { //procedimento } while ( x < y )
until( x < y ) { yield //procedimento
}
//podem ter o método continue e break.
do {
//procedimento
} until ( x < y )
--Comentários:
#comentário de unica linha
//comentário de unica linha
/* comentário de */multiplas linhas
--Funções: func correr (var a) { //faz algo return algo } .sucess { } .error { } .then { } .catch { } .finally { }
funcao () { //do anything }
--Tratamento de erros try{ } execept { } finally { }
--Fluxo
if (condição) { } else { }
if (condicao 1) { } elif { }
switch (valor) { case 1: //faça x //break não é necessário case 2, 3: default: }
unless (condicao) { }
label a goto a
--Orientação a objetos: class Animal { constructor(var a, var b) { this.a = a this.b = b }
func voar () { } }
class Cachorro extends Animal, Outro { }
class Gato implements Animal, Outro { super(a) //permite sobrescrita de métoco }
gato = Gato(var a, var b) //instanciação
static class Veiculo { }
abstract class Veiculo {
}
--Documentação: doc ('texto documentado') //receber um texto simples, caso precise de muitas linhas, passe como parâmetro um arquivo txt.
--Modificadores de acesso: ---em class, os atributos são privados e métodos são privados por padrão. funções em geral são públicas. ---public: blabla ---private: blabla ---protected: blabla
--Métodos padrão
map () lambda () int(), str(), double(), float(), ... find_one() find_all() exist() empty()
^ / %
<=
= === or // || and // && xor nor // !|| nand // !&& not // !
--Operadores de atribuição:
funções: -pass