kithon
kithon copied to clipboard
Match case support
For a while python has a match-case
statements When I ran the web version and tried to transpile this code to js:
# write your Python code...
print("hello world")
x = 1
match x:
case 1:
print("x is equal to 1")
case 2:
print("X is equal to 2")
if x == 1:
print("x = 1")
elif x == 2:
print("x = 2")
It transpiles to:
console.log("hello world");
let x = 1;
if (x === 1) {
console.log("x = 1");
} else if (x === 2) {
console.log("x = 2");
}
As you can see in the javascript code, there is nothing similiar to match case statements presented there, which could break some logic.
also screenshoot:
Thanks for the feedback. Match in python is not very simple operator, so now it don't support in kithon, but i plan implement it in next versions