Jump to content

Can use `this` to refer index_identifier of repeat-count statement?

Recommended Posts

For example, a callee action `foo` has a random variable `foo_val`. Then, another action calls `foo` in the repeat-count statement, using the `index_identifier` to constrain `foo_val`. For some reason, the name of `index_identifier` may be as same as `foo_val`.

action foo {
    rand int foo_val;

action main {
    activity {
        repeat (foo_val : 10) {
            do foo with { foo_val == this.foo_val; };

The question is, the built-in variable `this` can be used in this scenario?
Or I can only use different name for them?

repeat (i : 10) {
    do foo with { foo_val == i; };
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...