• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[solved]what the syntax for "if file not exists"?

 
L Willie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

don't know what the correct syntax for "if file not exists".

Sincerely

Willie

[ October 14, 2008: Message edited by: L Willie ]
[ October 15, 2008: Message edited by: L Willie ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't put an operator in the middle of a method call. It's "if (! file.exists())".
 
L Willie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank
 
Anton Pechsherov
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more simple:
 
Campbell Ritchie
Sheriff
Posts: 51368
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never write " == false" or " == true"; it is possible to make a mistake and write " = false" or " = true" instead in which case you have a serious logic error.

It would be much better to writeIf you write if (file.exists() = false), in this case it would probably be a compiler error.
 
Anton Pechsherov
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe , you can mistakes anywhere.. but it was enother Example ..
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anton Pechsherov:
Maybe , you can mistakes anywhere.. but it was enother Example ..


Yes, but the point is, it's a bad example, and one which we at the Ranch (as well as experienced programers everywhere) actively discourage people from following. I routinely tell people to never, under any circumstances, compare directly to a boolean literal; the tokens "==" or "!=" should never appear next to "true" or "false" in your code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic