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

Generate initializer in case multiple variables defined in a line. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tiennth
Copy link

@tiennth tiennth commented Feb 28, 2019

Support this case:
let keywords, selectedCategory: String

@tiennth tiennth changed the title Generate initializer in case multiple variable defined in a line. Generate initializer in case multiple variables defined in a line. Feb 28, 2019
Copy link
Owner

@Bouke Bouke left a comment

Choose a reason for hiding this comment

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

Thanks for reaching out and your contribution. Before merging this in, I would like to have a unit test that verifies the correctness of this change.


// In case multiple variables defined in a line.
let variableNames = variableName.components(separatedBy: ",")
for vname in variableNames {
Copy link
Owner

Choose a reason for hiding this comment

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

Variable names should be clearer. I.e. change the variable names around so the inner loop variable can be named variableName.

Copy link
Owner

Choose a reason for hiding this comment

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

You could also move this to the scanner part and use scanUpTo(characterSet:) to directly scan the variables into an array. That way there's no need to separate and trim them afterwards.

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