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

Qute: Support iterating by number #6971

Merged
merged 1 commit into from
Feb 4, 2020
Merged

Qute: Support iterating by number #6971

merged 1 commit into from
Feb 4, 2020

Conversation

gastaldi
Copy link
Contributor

@gastaldi gastaldi commented Feb 3, 2020

I reused the for instruction to iterate by number. Support for descending order is not yet implemented. Let me see how that works for you @lordofthejars

Fixes #6963

@gastaldi gastaldi requested a review from mkouba February 3, 2020 15:16
@gastaldi
Copy link
Contributor Author

gastaldi commented Feb 3, 2020

Also feel free to reject/close this PR if it doesn't make sense @mkouba :)

@lordofthejars
Copy link
Contributor

For me, it works really well as the only thing I want to do is print the number of stars depending on a rating number. So if it is 4 I just want to add 4 stars. The other thing as you said is the descending order but for now, if this is accepted I can work around the problem with not much effort.

Thank you very much.

@gastaldi
Copy link
Contributor Author

gastaldi commented Feb 3, 2020

The other thing as you said is the descending order but for now, if this is accepted I can work around the problem with not much effort.

Yeah, you can always do a total - (i - 1) instead of i if you want a descending order anyway :)

EDIT: It seems like math expressions are not supported yet

@gastaldi gastaldi marked this pull request as ready for review February 3, 2020 15:27
@mkouba
Copy link
Contributor

mkouba commented Feb 3, 2020

@gastaldi looks good ;-).

It seems like math expressions are not supported yet

Yep, complex expressions are not supported in loops.

By the way, you can also use the {#each} variant here, e.g. something like:

{#each movie.numberOfStars}
  ...print star
{/each}

@gastaldi gastaldi added this to the 1.3.0 milestone Feb 3, 2020
@gastaldi
Copy link
Contributor Author

gastaldi commented Feb 3, 2020

Can we get this PR approved and merged in time for 1.3.0.Alpha1?

@mkouba mkouba added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Feb 3, 2020
@gastaldi gastaldi modified the milestones: 1.3.0, 1.3.0.Alpha1 Feb 3, 2020
@gsmet
Copy link
Member

gsmet commented Feb 3, 2020

Just a small comment: let's not put pressure when none is needed. 1.3.0.Alpha1 is released for people to test the new class loading infra. We don't need to hurry to get this sort of fixes in: we can take our time to get a proper design if needed.

@gastaldi
Copy link
Contributor Author

gastaldi commented Feb 4, 2020

Hm, while reading the docs, I noticed that you could have also used an IntStream instead in an extension method:

Eg.

public IntStream getMovies() {
   return IntStream.rangeClosed(1, getMoviesCount()); 
}

Anyway, I added some docs adding support for plain Integers, let me know what you guys think :)

@gsmet
Copy link
Member

gsmet commented Feb 4, 2020

@mkouba could you review the doc?

@mkouba
Copy link
Contributor

mkouba commented Feb 4, 2020

@gastaldi Yes, extension methods would work too, ie. something like:

public static IntStream getMovieStars(Movie movie) {
   return IntStream.rangeClosed(1, movie.getStarsCount()); 
}

Anyway, I think it's ok to support this directly.

@gsmet gsmet merged commit a63bba5 into quarkusio:master Feb 4, 2020
@gastaldi gastaldi deleted the loop branch February 20, 2020 15:21
@DaHoC
Copy link

DaHoC commented Jul 4, 2024

Proposing to also support iterating Long numbers: #41679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qute iterating by number
5 participants