Is the Compiler Wrong? - Part II

17 June, 2008 (16:29) | Uncategorized

Here’s a simpler example of the previous post.  This won’t compile either.  Once again, the compiler reports that not all code paths return a value.  Is it wrong?

    string ThisWillNotCompile(bool input)
    {
        if (input)
            return "Hello, world.";

        if (!input)
            return "Howdy, world.";
    }
  • Digg
  • del.icio.us
  • Furl
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Write a comment