Good evening, I am working with goland and would like to know if an if check could be added. that you can use a variable defined within it if. it would be like an if line an idea would be this example of a simple return function
maybe it is impossible to do it but it will save a lot of code in large projects
async function boom() {
return { statusCode: 'success', data: [] }
}
if (let x = await boom() & x.statusCode === 'success' & ... /* conditions**/) {
console.log(x)
}
Yeah that would be my intuition too. I was just curious what others would assume, maybe another language does use that pattern for error management too?
I am working on a stream platform where we are with go and js. And with go it is less verbose instead with js you have to declare the function store it in a variable and then validate its output something that in go is on the same line and now a few lines this in a microservice would save us about 300 lines of code in a 900 system nearly a third