简体   繁体   中英

n.times do returns value of n

I have a problem with my code, I want it to display n number of stars. It display the right number of stars, plus the integer like ***3 I only want ***

show.html.slim

= article.rating_average.times do
  span
  i.fa.fa-star

Change = to - :

- article.rating_average.times do
  %span.fa.fa-star
  • = evaluates code and prints the returned value ( 3 is a return value of article.rating_average.times {} )
  • - just evaluates code (gives you 3 stars without the returned value printed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM