▲ 150 ▼ proportional reaction (lemmy.blahaj.zone) submitted 11 months ago by guber@lemmy.blahaj.zone to c/lemmyshitpost@lemmy.world 45 comments fedilink hide all child comments
[–] four@lemmy.zip 6 points 11 months ago (4 children) x = if y > 5 { "foo" } else { "bar" } This is just superior to anything else permalink fedilink source hideshow 8 child comments replies: [–] groctel@lemmy.world 3 points 11 months ago Never forget your roots (setq x (if (> y 5) :foo :bar)) permalink fedilink source parent [–] kryptonianCodeMonkey@lemmy.world 2 points 11 months ago (2 children) In what language is that valid syntax? permalink fedilink source parent hideshow 4 child comments replies: [–] calcopiritus@lemmy.world 3 points 11 months ago This is valid rust. I don't know if there are more languages with this feature permalink fedilink source parent [–] four@lemmy.zip 2 points 11 months ago This is Rust syntax, but there's similar syntax in Haskell permalink fedilink source parent [–] thebestaquaman@lemmy.world 2 points 11 months ago (2 children) I honestly can't see how this is more readable than x = (y > 5) ? "foo" : "bar" I get that it's a syntax that needs to be learned, but it's just so clean and concise! permalink fedilink source parent hideshow 4 child comments replies: [–] calcopiritus@lemmy.world 3 points 11 months ago Because it can be done for multiple lines too. And you can do else-if too. Also, "if" and "else" is more recognizable than "?" and ":" x = if y > 5 { println!("Y was over 5"); z + 5 } else if y < 0 { handle_negative_y(y); z - y } else { println!("<WARN> unexpected value for y"} 0 } permalink fedilink source parent [–] four@lemmy.zip 1 point 11 months ago (2 children) What I like about using if and else for that is that you're already using those keywords for branching in other parts of the code. Though my least favorite is probably Python's: x = "foo" if y > 5 else "bar" It just seems backwards to me permalink fedilink source parent hideshow 4 child comments replies: [–] UnfortunateShort@lemmy.world 1 point 11 months ago* Because Python wants you to read it like English: x is "foo" if y is greater than 5, else it is "bar" permalink fedilink source parent [–] thebestaquaman@lemmy.world 1 point 11 months ago* (1 child) While Python's version does feel a bit backwards, it's at least consistent with how list comprehensions are set up. They can also feel a bit "backwards" imo, especially when they include conditionals. permalink fedilink source parent hideshow 2 child comments replies: [–] four@lemmy.zip 1 point 11 months ago (1 child) List comprehension is another thing I don't like about Python :) There's more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much permalink fedilink source parent hideshow 2 child comments replies: [–] kryptonianCodeMonkey@lemmy.world 3 points 11 months ago I love list comprehension. Best part of the language, imo. To each their own. permalink fedilink source parent [–] humanspiral@lemmy.ca 2 points 11 months ago ('bar',:'foo')&({~ 5&< ) permalink fedilink source parent
[–] groctel@lemmy.world 3 points 11 months ago Never forget your roots (setq x (if (> y 5) :foo :bar)) permalink fedilink source parent
[–] kryptonianCodeMonkey@lemmy.world 2 points 11 months ago (2 children) In what language is that valid syntax? permalink fedilink source parent hideshow 4 child comments replies: [–] calcopiritus@lemmy.world 3 points 11 months ago This is valid rust. I don't know if there are more languages with this feature permalink fedilink source parent [–] four@lemmy.zip 2 points 11 months ago This is Rust syntax, but there's similar syntax in Haskell permalink fedilink source parent
[–] calcopiritus@lemmy.world 3 points 11 months ago This is valid rust. I don't know if there are more languages with this feature permalink fedilink source parent
[–] four@lemmy.zip 2 points 11 months ago This is Rust syntax, but there's similar syntax in Haskell permalink fedilink source parent
[–] thebestaquaman@lemmy.world 2 points 11 months ago (2 children) I honestly can't see how this is more readable than x = (y > 5) ? "foo" : "bar" I get that it's a syntax that needs to be learned, but it's just so clean and concise! permalink fedilink source parent hideshow 4 child comments replies: [–] calcopiritus@lemmy.world 3 points 11 months ago Because it can be done for multiple lines too. And you can do else-if too. Also, "if" and "else" is more recognizable than "?" and ":" x = if y > 5 { println!("Y was over 5"); z + 5 } else if y < 0 { handle_negative_y(y); z - y } else { println!("<WARN> unexpected value for y"} 0 } permalink fedilink source parent [–] four@lemmy.zip 1 point 11 months ago (2 children) What I like about using if and else for that is that you're already using those keywords for branching in other parts of the code. Though my least favorite is probably Python's: x = "foo" if y > 5 else "bar" It just seems backwards to me permalink fedilink source parent hideshow 4 child comments replies: [–] UnfortunateShort@lemmy.world 1 point 11 months ago* Because Python wants you to read it like English: x is "foo" if y is greater than 5, else it is "bar" permalink fedilink source parent [–] thebestaquaman@lemmy.world 1 point 11 months ago* (1 child) While Python's version does feel a bit backwards, it's at least consistent with how list comprehensions are set up. They can also feel a bit "backwards" imo, especially when they include conditionals. permalink fedilink source parent hideshow 2 child comments replies: [–] four@lemmy.zip 1 point 11 months ago (1 child) List comprehension is another thing I don't like about Python :) There's more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much permalink fedilink source parent hideshow 2 child comments replies: [–] kryptonianCodeMonkey@lemmy.world 3 points 11 months ago I love list comprehension. Best part of the language, imo. To each their own. permalink fedilink source parent
[–] calcopiritus@lemmy.world 3 points 11 months ago Because it can be done for multiple lines too. And you can do else-if too. Also, "if" and "else" is more recognizable than "?" and ":" x = if y > 5 { println!("Y was over 5"); z + 5 } else if y < 0 { handle_negative_y(y); z - y } else { println!("<WARN> unexpected value for y"} 0 } permalink fedilink source parent
[–] four@lemmy.zip 1 point 11 months ago (2 children) What I like about using if and else for that is that you're already using those keywords for branching in other parts of the code. Though my least favorite is probably Python's: x = "foo" if y > 5 else "bar" It just seems backwards to me permalink fedilink source parent hideshow 4 child comments replies: [–] UnfortunateShort@lemmy.world 1 point 11 months ago* Because Python wants you to read it like English: x is "foo" if y is greater than 5, else it is "bar" permalink fedilink source parent [–] thebestaquaman@lemmy.world 1 point 11 months ago* (1 child) While Python's version does feel a bit backwards, it's at least consistent with how list comprehensions are set up. They can also feel a bit "backwards" imo, especially when they include conditionals. permalink fedilink source parent hideshow 2 child comments replies: [–] four@lemmy.zip 1 point 11 months ago (1 child) List comprehension is another thing I don't like about Python :) There's more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much permalink fedilink source parent hideshow 2 child comments replies: [–] kryptonianCodeMonkey@lemmy.world 3 points 11 months ago I love list comprehension. Best part of the language, imo. To each their own. permalink fedilink source parent
[–] UnfortunateShort@lemmy.world 1 point 11 months ago* Because Python wants you to read it like English: x is "foo" if y is greater than 5, else it is "bar" permalink fedilink source parent
[–] thebestaquaman@lemmy.world 1 point 11 months ago* (1 child) While Python's version does feel a bit backwards, it's at least consistent with how list comprehensions are set up. They can also feel a bit "backwards" imo, especially when they include conditionals. permalink fedilink source parent hideshow 2 child comments replies: [–] four@lemmy.zip 1 point 11 months ago (1 child) List comprehension is another thing I don't like about Python :) There's more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much permalink fedilink source parent hideshow 2 child comments replies: [–] kryptonianCodeMonkey@lemmy.world 3 points 11 months ago I love list comprehension. Best part of the language, imo. To each their own. permalink fedilink source parent
[–] four@lemmy.zip 1 point 11 months ago (1 child) List comprehension is another thing I don't like about Python :) There's more of those, but one thing I do like about Python is that I get paid for writing it, so I try not to complain too much permalink fedilink source parent hideshow 2 child comments replies: [–] kryptonianCodeMonkey@lemmy.world 3 points 11 months ago I love list comprehension. Best part of the language, imo. To each their own. permalink fedilink source parent
[–] kryptonianCodeMonkey@lemmy.world 3 points 11 months ago I love list comprehension. Best part of the language, imo. To each their own. permalink fedilink source parent
[–] humanspiral@lemmy.ca 2 points 11 months ago ('bar',:'foo')&({~ 5&< ) permalink fedilink source parent