We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b58c79c commit 580d3a9Copy full SHA for 580d3a9
chapters/strings/repeating.textile
@@ -10,12 +10,14 @@ You want to repeat a string.
10
11
h2. Solution
12
13
-Use a list comprehension that ignores the list:
+Use a map or a list comprehension, and flatten it:
14
15
{% highlight coffeescript %}
16
-# repeat 'foo' 10 times
17
('foo' for dummy in [1..10]).join ''
18
# => "foofoofoofoofoofoofoofoofoofoo"
+
19
+([1..10].map (x) -> 'foo').join ''
20
+# => "foofoofoofoofoofoofoofoofoofoo"
21
{% endhighlight %}
22
23
Or a simple (but stateful) loop:
0 commit comments