Yes, it's similar to rusts ? operator.
let result = my_function();
if result.is_error() return result.error;
let value = result.value();
or something similar can be done in any language,
but the try just makes it convenient.
Idk, I donāt have a lot of experience in error handling in such languages but I do think it has its benefits, but exceptions, especially in combination with try blocks, are reaaaaally useful sometimes because you donāt have to handle errors everywhere
Rust's result is the same as only checked exceptions.
I just prefer the explicit
my_fun()?;
instead of
my_fun();
to know that it may bubble up the error. What I love about Rust is that you yan can do
my_fun().unwrap();
to just crash the program when an error occurs and then just find all unwrap()s later.
This is true, though Java doesn't give you a choice a lot of times when some libraries have methods that require an exception in the method or a try catch block, regardless of how well your flow is.
Safe coding? If theres an error itās cearly the userās fault since my code is perfect since I found it on chat gpt and stack overflow. Itās best that they suffer for their own mistakes rather than me
finally
Applause
I love languages without exceptions š
No exceptions?
yes like C, Zig, Rust, Roc, sometimes C++
Wooosh
haha just got it now I'm dumb šš
Roc? Thatās a new one.
It's very cool if you're into functional programming, it's early development though.
Zig still has try keyword
Yes, it's similar to rusts ? operator. let result = my_function(); if result.is_error() return result.error; let value = result.value(); or something similar can be done in any language, but the try just makes it convenient.
You're talking about Javascript?
My code's love language is exceptions.
Lol
I love Rust, too
Idk, I donāt have a lot of experience in error handling in such languages but I do think it has its benefits, but exceptions, especially in combination with try blocks, are reaaaaally useful sometimes because you donāt have to handle errors everywhere
You donāt need a special language to not handle errors everywhere. ;)
Yessss but sometimes you shouldš
Rust's result is the same as only checked exceptions. I just prefer the explicit my_fun()?; instead of my_fun(); to know that it may bubble up the error. What I love about Rust is that you yan can do my_fun().unwrap(); to just crash the program when an error occurs and then just find all unwrap()s later.
I miss working with Visual Basic's awesome "On Error Resume Next" switch.
Only a sith deals in absolutes.
Took me a bit to CATCH the joke
Honestly not terrible advice. I generally try to use try as a method of least resort, if statements give far more control over the workflow.
This is true, though Java doesn't give you a choice a lot of times when some libraries have methods that require an exception in the method or a try catch block, regardless of how well your flow is.
Do while or throw an exception, there is no try.
Safe coding? If theres an error itās cearly the userās fault since my code is perfect since I found it on chat gpt and stack overflow. Itās best that they suffer for their own mistakes rather than me
Exceptional
Where's the catch block?
Rust team refusing to stabilize \`try\` blocks:
No try, no catch. Do or die.
Golang has entered the chat
But try{} makes everything easier!