Small Query in "if then else"

i can pass “set variable to” block in a ‘if then else’ statement like this :
blocks (1)

But how to do it here :
controls_choose

i tried this :
blocks (2)
will it work ( i don’t know i am not able to connect to companion )

Sorry if that was DUMB.

this block is to return and not set something if a condition happened. But still you can set something in it using the do result block in the control blocks.

1 Like

i was editing the First Post.

you Type freaking Fast.
:keyboard:

:sunglasses:

Yes it will work but you must return something.As the base of this block is if then return and not if then do so you will need to return something from the do result block so it can be returned by the if then block ( if the condition went true )

Both do same work but you can see the different in block … I hope It will help you

1 Like

i know both do the same work.

But here the Scenario and my Question both are Different.

But Still,

Thankyou for your Time.

1 Like

Yes

:thinking:

@ADDYLIN you have studied conditional operator in cpp, and that can be used instead of if_then_else right? I hope now you got it

Sometimes in a procedure or another block of code, you may need to do something and return something, but for various reasons you may choose to use this block instead of creating a new procedure

From docs

Not yet, but definitely in future.

:thinking:

Don’t know.

You introduced me with 2 new terms which i heard for the first time.
:stuck_out_tongue_closed_eyes:

Well google it
Cpp - c++

Google is your friend :shushing_face:

And @ADDYLIN check the docs

i heard of C++
but today i came to know it’s also called Cpp

This makes me speak -
Knowledge is a vast ocean. What i know is infinitesimally smaller than what we don’t know.

1 Like

Let me tell both usage of both blocks are different.
If then block with setting variable is useful when you have more than one thing to do and not return value to any variable.
Eg.
If (true){ alert('hi'); console.log('is true') }
This is the root procedure or function that returns nothing.

For second If then is one line statement mainly in programming language like.
const data = If (true){ return ' available' }else {return 'not available'}

Used this block when you want value in variable or procedure thats changes input According to data input.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.