I don't know why it works?

Hello

I read a book on Actionscript 3 and I'm good! But I have a question:

Look at this code that I find in my book (it is in a class file):

public void setNom (pNom:String): void

                                    {

                                                      If (pNom.length < = 30) name = pNom.

                                                     

another path ("the name specified is too long");                  

                                    }

I found the proper syntax for this:

public void setNom (pNom:String): void

                                    {

                                                      If (pNom.length < = 30) {}


name = pNom;

                                                    

                                                     } else {


trace ("the specified name is too long");                

                                    }

}

In the first example (of the book), the braces are missing... But it has worked so far! The application works properly!

I don't know why? I thought was if else statement requires braces around it! Also, when I press the button in the form of the syntax, Flash adds the 'missing '... braces

I thought that it was a mistake in the book and would like to get a syntax error here... But apparently, it's good... Usually, when your code is wrong, you cannot format your syntax...

Can someone help me out here?

Thanks a lot for your help!

--

Martin

http://www.martinc.biz

It's because you only have a single statement for the fi, and for the rest, it's the kind of a shortcut, however if you try to add a second statement at the END, otherwise you will get a compiler error. It's like semicolons, they are not really necessary unless you write two statements on the same line of code.

Tags: Adobe Animate

Similar Questions

Maybe you are looking for

  • Connections to the Web site

    Since the update of Firefox for windows 10 I cant get onto certain websites.All I get is the error message. Tried removing Firefox firewall and adding back on. Don't agree.Never had any problem until I updated. I have triewd the removal of Firefox an

  • Satellite L100-179 - possible to use a WLAN PC card?

    Is it possible to use expansion wireless PC card? If so do what card you recommend, I need to connect to a local network. Thanks Dan.

  • Camileo H20 accessories

    Hello people, I just got myself one of these little gems (incredible value/spec) but I would buy one of the two accessories for it.More importantly, I would like a lens cap/cover.My second question would be a practical bag designed for its size.The s

  • Run Vista64 installation without back to their original factory condition?

    Is there a way to run a Vista64 OS repair without having to return to their original factory condition?  I cloned my HD 600GIG that came in my a6530f to a GIG HD 1000 Pavilion and uses the original HD as an external drive for backup using an eSATA in

  • need driver for network card

    I need the network card driver for my desktop sff EVO 510 with XP pro, Ive tried the HP/Compaq downloads and none of these work