Skip to content

Conversation

ValKmjolnir
Copy link
Collaborator

pub fn getParentByLevel(self, level: int) -> Self {
    if (level = 1) {
        return self.getParent()
    }

    let (p = self.getParent().getParentByLevel(level - 1)) {
    //                                         ^^^^^ level is not bound in this expression,
    //                                               `level - 1` is in fact a filter condition
        return p
    }
}

Copy link
Collaborator

@xiexie xiexie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@xiexie xiexie merged commit 89bac38 into main Feb 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants