Language-specific · 43
What makes Craykon different
Keywords in your own language, a null that stops calculations, a strict ==, and a switch that never falls through.
This lesson is for Craykon.
This lesson is about Craykon itself.
The other 7 languages have English keywords only (if, for, return).
Craykon lets you write keywords in your own language, and its null, == and switch are stricter than in other languages.
The example below takes a list of scores where absences (-) are stored as null, skips the nulls, grades the rest with switch, and prints the average.
n = Console.ReadLine().ToNumber();점수들 = [];for (i = 0; i < n; i++){ 줄 = Console.ReadLine(); if (줄 == "-") { 점수들.Add(null); } else { 점수들.Add(줄.ToNumber()); }}합 = 0;낸사람 = 0;foreach (점수 in 점수들){ if (점수 == null) { Console.WriteLine("? " + 점수); continue; } 합 += 점수; 낸사람 += 1; switch (Mathf.Floor(점수 / 10)) { case 10: case 9: Console.WriteLine(점수 + " A"); break; case 8: Console.WriteLine(점수 + " B"); break; default: Console.WriteLine(점수 + " C"); break; }}Console.WriteLine(합 / 낸사람);Console.WriteLine("85" == 85);5 92 - 78 85 -
92 A ? 빈값 78 C 85 B ? 빈값 85 false
Key points
- Keywords can be written in your own language.
You can even mix languages in one script and it is still the same program, so만약 (n > 3) { Console.WriteLine(n); }runs fine. - Only one program is stored and run, so when you change the screen language, the same code is printed again in that language.
In the editor the same code can also be built from tiles, and you can switch between tiles and text while editing. nullmeans 'no value' (Python'sNone).
Calculating with null or comparing its size stops the program right there.
Joining it to text does not stop; it shows as빈값, Craykon's Korean name for null (the example's? 빈값).==is strict.
Values of different types are never equal, so0 == falseisfalse.
Think of it as JavaScript's===.switchruns only the matching case and never falls through, so you do not needbreak.
List several values with commas, as incase 10, 9:.- There is only one kind of number (a 64-bit floating-point number, as in JavaScript).
7 / 2is3.5, so the tens digit isMathf.Floor(score / 10)and integer division isMathf.Quot(7, 2)(→3).
Integers above 2^53 are not exact.
How each language writes it
| Craykon | The English keywords if, else, for, foreach, while, return, switch are 만약, 아니면, 반복, 각각, 동안, 돌려주기, 선택 in Korean, もし, 繰り返す… in Japanese and 如果, 循环… in Chinese.Names work the same way: Console.WriteLine, 콘솔.쓰기, コンソール.書く and 控制台.输出 are all the same thing |
|---|
Common mistakes
Calculating with null
score = null;
Console.WriteLine(score + 1);→ It stops with an error saying it cannot calculate with null (+). JavaScript quietly gives 1 for null + 1 and NaN for undefined + 1, a wrong number with no warning; Craykon never produces one
Before calculating, ask first with if (score == null).
Using a keyword as a variable name
case = 3;→ An error saying 'case' and 'default' belong inside a switch. The keywords of every language are reserved, so me, case, in, 나 or 場合 cannot be names either
Pick a name that is not a keyword.
Comparing text you read with a number
Console.WriteLine("85" == 85);→ false — a value read with Console.ReadLine() is always text, and == is false when the types differ
Convert it with .ToNumber() before comparing it with a number.
Null stops the program the moment it enters a calculation.
If a list or the input may contain null, filter it out with
== null before adding or comparing.