kithon icon indicating copy to clipboard operation
kithon copied to clipboard

Match case support

Open NOTMEE12 opened this issue 1 year ago • 1 comments

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: screenshot shows that match case is not present in js code

NOTMEE12 avatar Jan 20 '24 21:01 NOTMEE12

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

alploskov avatar Jan 20 '24 23:01 alploskov