generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Conditional Assignment

Previous Thread :: Next Thread 
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
06 Dec 2016 09:39 PM
Is it bad to write stuff like this?

local x=("y"):byte()
x=x%2==1 and x-1 or x
print(x)

instead of

local x=("y"):byte()
if x%2==1 then
x=x-1
end
print(x)

I have only ever seen one other person use the first one.


Report Abuse
xXIcanthinkofanameXx is not online. xXIcanthinkofanameXx
Joined: 05 May 2012
Total Posts: 857
06 Dec 2016 09:42 PM
I used to do it a lot. I think it makes the code a bit harder to read.
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
06 Dec 2016 09:51 PM
oh


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Dec 2016 09:54 PM
Yeah typically it makes it harder to read.
Doing something like:

optParam = optParam or defaultValue is fine IMO though
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
06 Dec 2016 09:59 PM
it makes the code easier to write


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
06 Dec 2016 10:01 PM
I use it all the time.


Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
06 Dec 2016 10:05 PM
ah okay :)


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image