You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scala...@googlegroups.com
Hi, I have the following code segment
var reader = new BufferedReader(new InputStreamReader(new FileInputStream("file.txt"))) var line:String = null while(!((line = reader readLine) == "")) {
// my code here }
In Eclipse while editing the code the editor is showing an error that comparing Unit and java.lang.String using ' == ' will always yield false. Why is it so? I am comparing 2 String objects only. How come Unit is coming in?
Thanks, Sankha Narayan Guria
Rex Kerr
unread,
May 31, 2012, 3:06:19 AM5/31/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Sankha Narayan Guria, scala...@googlegroups.com
Assignments return unit, not the value that was assigned.
Change that to { line = reader readLine; line } == "" and it should compile (and possibly even do what you want).
--Rex
Ken Scambler
unread,
May 31, 2012, 3:05:22 AM5/31/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Sankha Narayan Guria, scala...@googlegroups.com
Assignment always returns Unit; you can't use this idiom in Scala. Most style guides in Java, C++, etc would discourage assignment within if/while conditions anyway.