This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unexcepted Types... why?

 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Simple prgm. To run it you need an external .txt file called "Init.txt".

What this prgm is meant to do is create separate .txt file for each student. The .txt files should be named according to the ID (which MUST have 4 numbers and range from 1000-9999). When adding, it first needs to search for an available slot starting from 1000.

The problem occurs here: if(temp_file.exists() = false)
I've tested the .exists() method and I know it returns true or false, yet the complier tells me:

unexpected type


why?...
 
Vijay Raj
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to check for true or false right, and not assign the value false. So, maybe == will help, rather than just =



Vijay.
 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh right... how dum of me

Thanks loads... fixed the problem
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better way would be:

if(!temp_file.exists())
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic