Mailinglist Archive: yast-devel (157 mails)

< Previous Next >
[yast-devel] YCP return bug?
  • From: "Benji Weber" <b.weber@xxxxxxxxxxxxx>
  • Date: Mon, 11 Jun 2007 19:19:17 +0100
  • Message-id: <d6b310ce0706111119u5bd45b90y8e7cd015d5d92650@xxxxxxxxxxxxxx>
Hi all,

Could someone tell me whether this is a bug in YCP or if I am
misunderstanding the documentation, it is certainly counter-intuitive.

The documentation
(http://forgeftp.novell.com//yast/doc/SL10.2/tdg/id_ycp_return.html)
states:

The return statement immediately leaves the current function or a
current top level block (that contains it) and optionally assigns a
return_value to this block. If blocks are nested, i.e. if the current
block is contained in another block, the return statement leaves all
nested blocks and defines the value of the outermost block.

Therefore I would expect the following programme to print "One" "Two"
"Three". However, it actually prints "One" "One" "Three".

{
        string One()
        {
                return "One";
        }

        string Two()
        {
                string value = "One";
                foreach(string str, ["Two"],
                {
                        return str;
                });
                return value;
        }

        string Three()
        {
                string value = "One";
                foreach(string str, ["Three"],
                {
                        value = str;
                });
                return value;
        }

        y2milestone(One());
        y2milestone(Two());
        y2milestone(Three());
}

_
Benjamin Weber
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups