pseudo-lang / pseudo

transpile algorithms/libs to idiomatic JS, Go, C#, Ruby
MIT License
685 stars 43 forks source link

can't change the type of variable string in global scope from String to List[String] #21

Closed notzoom closed 6 years ago

notzoom commented 6 years ago

Trying to translate this Python program to JS:

string = "I am fine"

string = string.split(" ")

string = string[0]

What I get is: can't change the type of variable string in global scope from String to List[String]

alehander92 commented 6 years ago

That's intended.

s = "I am fine"
l = s.split(" ")
s = l[0]
print(s)

works

Pseudo translates only a limited subset of Python which is statically typed. You don't write any types, because it has full type inference, but changing the type of a variable is forbidden