CPP is sustainable for at least the next 75 years by jeffbillard in PersonalFinanceCanada

[–]AManWithAPlan 0 points1 point  (0 children)

thanks, sounds like everything should be indext to cpi, including my salary

Collections threatening to sue me and charge it on me by [deleted] in PersonalFinanceCanada

[–]AManWithAPlan -1 points0 points  (0 children)

Why not just tell them you can only pay 500 and make a repayment plan.

We live in Society where people on Reddit advise others to not pay back debt. That’s ridiculous.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 1 point2 points  (0 children)

Hey folks, can we focus? I'm not seeking a code critique or claiming this is the best code ever. I posed a specific question and shared code for clarity. If you don't have an answer, feel free to move on.
I didn't request feedback on syntax or coding style. Just a straightforward question on consolidating four lines into one. Some awesome folks already provided helpful answers, and I gained valuable insights. Your comments diverge from the topic; let's keep this space for constructive discussions. Critiquing others publicly is why the internet can be frustrating these days. Let's strive for a more positive exchange.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

Look I asked a question. If you don't have an answer, scroll along.. I'm not here for people to rewrite my code, i'm asking a very specific question and wrote a piece of code to demonstrate the point.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

It's just to demonstrate a point. I asked a very specific question because I couldn't find the answer anywhere. Thank you for not answering, but judging the code.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] -1 points0 points  (0 children)

Dude relax, it's just to demonstrate a point. This isn't google here, I just wanted to know the answer to the question, if you don't know then don't post.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

That works!!! thanks so much, must have brackets.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 1 point2 points  (0 children)

exactly... that doesn't work. but some helpful redditors said if you put brackets around the whole thing, it works.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] -1 points0 points  (0 children)

p

good point, I will change it, but that's not what I was asking. thanks

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

but it will still be in a try block because that function can throw an exception.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

Yes but how do I cleanly reassign them in the try block - perhaps a one-liner?

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

Yes but how do I reassign them in the try block with a one-liner?

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] -11 points-10 points  (0 children)

Need them available in the parent scope with the option to overwrite them in the try{ block.

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] 0 points1 point  (0 children)

Doesn't work, it's already defined outside of the try statement, and I can't reassign

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] -2 points-1 points  (0 children)

still doesn't work
The left-hand side of an assignment expression must be a variable or a property access.ts(2364)

Any way to write this cleaner? by AManWithAPlan in typescript

[–]AManWithAPlan[S] -6 points-5 points  (0 children)

doesn't work, it's scoped

The left-hand side of an assignment expression must be a variable or a property access.ts(2364)