Repeat a string n times in elixir

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?

Answers


You can use String.duplicate/2:

iex(1)> str = String.duplicate("a", 5)
"aaaaa"

Need Your Help

What does the --stdlayout do in git svn clone?

svn git git-svn

I just spotted this question about recovering from a clone done without --stdlayout. I didn't find documentation of this flag - what does it do?

Ant, (over)write into a file

file scripting ant

How to write (or overwrite) the following contents: