Problem with return string in function

40 views
Skip to first unread message

Yehudit R

unread,
Jun 9, 2015, 5:59:41 AM6/9/15
to nemer...@googlegroups.com
I want to return string in a function, this is my function:
public expression(curLine:String):String
      {
          print("expression");
          term(curLine);
          mutable l = input.ReadLine();
          while(l.Contains("+")||l.Contains("-")||l.Contains("> / <")||l.Contains("&amp")||l.Contains("|")||l.Contains("&gt")||l.Contains("&lt")||l.Contains("="))
          {
              printLine(l);//op
              term(input.ReadLine());//term
              l = input.ReadLine();
          }
          print("/expression");
          if(l!=null)
            return "vhvh";
          else return "xbb";
      }

and I got the following error:
Cannot implicitly convert type 'void' to 'string'.
What am I doing wrong?
Thank you!
לכידה.PNG

Dustin Mays

unread,
Jun 9, 2015, 10:18:04 AM6/9/15
to nemer...@googlegroups.com
You don't need to use the 'return' keyword. Nemerle automatically returns the last-evaluated expression.

--
--
nemerle-en Google Group, try http://groups.google.com/group/nemerle-en
for more options.
---
You received this message because you are subscribed to the Google Groups "Nemerle Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nemerle-en+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yehudit R

unread,
Jun 9, 2015, 11:40:58 AM6/9/15
to nemer...@googlegroups.com
Yes, it worked, Thank you!!
Reply all
Reply to author
Forward
0 new messages