Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccessible error condition #5

Open
inhies opened this issue Jun 2, 2019 · 0 comments
Open

Inaccessible error condition #5

inhies opened this issue Jun 2, 2019 · 0 comments

Comments

@inhies
Copy link

inhies commented Jun 2, 2019

I believe the if !ok check in the bottom of this snippet is inaccessible and therfore not required, due to the check for entity.tag.matches(tag) prior to it. I cannot come up with a situation in which the first tag check would pass but the attempt to get component data would fail. Is this correct? Code inserted below for your reference:

func (manager *Manager) fetchComponentsForEntity(entity *Entity, tag Tag) map[*Component]interface{} {

	if !entity.tag.matches(tag) {
		return nil
	}

	componentMap := make(map[*Component]interface{})

	for _, component := range manager.components {
		if tag.matches(component.tag) {
			data, ok := entity.GetComponentData(component)
			if !ok {
				return nil // if one of the required components is not set, return nothing !
			}```
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

No branches or pull requests

1 participant