Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1437 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

do NOT use {} for single if-else statements..

Thread title: do NOT use {} for single if-else statements..
Closed Thread  
Page 3 of 3 < 1 2 3
    Thread tools Search this thread Display Modes  
02-22-2007, 10:52 AM
#21
jono1 is offline jono1
jono1's Avatar
Status: Non-conformist
Join date: Jul 2005
Location: Canberra, Australia.
Expertise:
Software:
 
Posts: 1,172
iTrader: 0 / 0%
 

jono1 is on a distinguished road

  Old

I always prefer to use the braces simply because that's the coding technique I've developed for myself that works for me. If I stopped using them, sure I'd save a whole 4 bytes of code every time I had to use a conditional like that, but I'd get very confused very quickly.

I didn't know about the ternary operator though. Thanks for that.

02-26-2007, 01:18 AM
#22
deLive is offline deLive
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 8
iTrader: 0 / 0%
 

deLive is on a distinguished road

  Old

Thats how it works in Java, though I'm not sure how efficient it is in PHP

02-28-2007, 08:59 PM
#23
bluesaga is offline bluesaga
Status: Member
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 137
iTrader: 1 / 100%
 

bluesaga is on a distinguished road

  Old

Originally Posted by Dizzee View Post
i dont know php... but c++ works in the same way...

but personally i always use {}, you never know when you will have to add extra lines of code and in general it just looks better...
I do the same, im always adding "print 'did you get here yet?';" to my if's for debugging

02-28-2007, 09:59 PM
#24
bloodystones is offline bloodystones
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

bloodystones is on a distinguished road

  Old

Even if it does work, I wouldn't change my style for no good reason

03-02-2007, 12:07 PM
#25
bluesaga is offline bluesaga
Status: Member
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 137
iTrader: 1 / 100%
 

bluesaga is on a distinguished road

  Old

Im pretty sure the speed increase is neglegible anyway. Brackets it is!

Closed Thread  
Page 3 of 3 < 1 2 3


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed