Question
· 2 hr ago

Quit or Return?

Hi developers!

I'm testing vibecoding with ObjectScript and my silicon friend created a code-block that got me thinking "what's wrong"?

Here is the piece of code:

for i=0:1:(json.%Size()-1) {

set p = json.%Get(i)

if (p="value1")!(p="value2") {

quit 1

}

 

AI wanted to quit from a method with a return value. Good intention, but bad use of the command.

And ObjectScript compiler compiles this code with no error(?) (syntax linter in VSCode says it's a syntax, kudos @Brett Saviano ).

But in action, it produces <COMMAND>, of course.

Wanted to share with you as this is a good case where return command is better than quit, so if we change the snippet to use return, everything will be fine:

for i=0:1:(json.%Size()-1) {

set p = json.%Get(i)

if (p="value1")!(p="value2") {

return 1

}

So I told my AI-companion to go with return further while returning method results.

Do you use return? Or quit? 

Discussion (1)1
Log in or sign up to continue