View Source Miss.String (Miss Elixir v0.1.5)
Functions to extend the Elixir String
module.
Link to this section Summary
Functions
Builds a string with the given values using IO lists.
Builds a string with the given two values using IO lists similar to Miss.String.build/1
.
Builds a string with the given three values using IO lists similar to Miss.String.build/1
.
Builds a string with the given four values using IO lists similar to Miss.String.build/1
.
Builds a string with the given five values using IO lists similar to Miss.String.build/1
.
Link to this section Functions
Specs
Builds a string with the given values using IO lists.
In Erlang and Elixir concatenating binaries will copy the concatenated binaries into a new
binary. Every time you concatenate binaries (<>
) or use interpolation (#{}
) you are making
copies of those binaries.
To build a string, it is cheaper and more efficient to use IO lists to build the binary just once instead of concatenating along the way.
See the Elixir IO Data documentation for more information.
All elements in the list must be a binary or convertible to a binary, otherwise an error is raised.
examples
Examples
iex> Miss.String.build(["akira", "hamasaki", "123", "pim", "2010-09-01", "99.99"])
"akirahamasaki123pim2010-09-0199.99"
iex> Miss.String.build([:akira, 'hamasaki', 123, [112, 105, 109], ~D[2010-09-01], 99.99])
"akirahamasaki123pim2010-09-0199.99"
Specs
Builds a string with the given two values using IO lists similar to Miss.String.build/1
.
When both values are binary, Miss.String.build/2
is more efficient than
Miss.String.build/1
because it avoids to check if each value is a binary.
examples
Examples
iex> Miss.String.build("akira", "hamasaki")
"akirahamasaki"
iex> Miss.String.build(:akira, 'hamasaki')
"akirahamasaki"
Specs
Builds a string with the given three values using IO lists similar to Miss.String.build/1
.
When all the values are binary, Miss.String.build/3
is more efficient than
Miss.String.build/1
because it avoids to check if each value is a binary.
examples
Examples
iex> Miss.String.build("akira", "hamasaki", "123")
"akirahamasaki123"
iex> Miss.String.build(:akira, 'hamasaki', 123)
"akirahamasaki123"
Specs
Builds a string with the given four values using IO lists similar to Miss.String.build/1
.
When all the values are binary, Miss.String.build/4
is more efficient than
Miss.String.build/1
because it avoids to check if each value is a binary.
examples
Examples
iex> Miss.String.build("akira", "hamasaki", "123", "pim")
"akirahamasaki123pim"
iex> Miss.String.build(:akira, 'hamasaki', 123, [112, 105, 109])
"akirahamasaki123pim"
Specs
Builds a string with the given five values using IO lists similar to Miss.String.build/1
.
When all the values are binary, Miss.String.build/5
is more efficient than
Miss.String.build/1
because it avoids to check if each value is a binary.
examples
Examples
iex> Miss.String.build("akira", "hamasaki", "123", "pim", "2010-09-01")
"akirahamasaki123pim2010-09-01"
iex> Miss.String.build(:akira, 'hamasaki', 123, [112, 105, 109], ~D[2010-09-01])
"akirahamasaki123pim2010-09-01"