Reputation: 620
I need to make a string of a defined length. In ruby, I would use:
str = 'a' * 5
How do I accomplish the same thing in elixir?
Upvotes: 19
Views: 8045
Reputation: 222188
You can use String.duplicate/2
:
iex(1)> str = String.duplicate("a", 5)
"aaaaa"
Upvotes: 45