most languages come up with a way to distinguish readonly and mutable variables, and oh-lang is no different. in Rust, let x = 3; is a readonly, while let mut y = 4; is mutable. the same thing in C might be const int x = 3; and int y = 4; . oh-lang goes all in on concision and writes these as x: 3 and y; 4 . yes, oh-lang makes the questionable life choice of appropriating everyone's favorite statement ender™ ; for mutable variable declarations. why? well, like python, oh-lang doesn't need ; to end statements. we infer you are trying to end a statement by various implicit rules (like doing a newline without tabbing), or explicitly using , . that frees ; for something else, and because it looks like : , which we use for declaring readonly variables, we decided it would make sense to declare writable variables. we also use it for "short-hand" to declare methods that can mutate the class instance ( ;;my_mutating_method() ), in analogy with methods that ke...
- Get link
- X
- Other Apps