Miss.String (Miss Elixir v0.1.2) View Source

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

build(list()) :: String.t()

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

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

build(term(), term()) :: String.t()

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

iex> Miss.String.build("akira", "hamasaki")
"akirahamasaki"

iex> Miss.String.build(:akira, 'hamasaki')
"akirahamasaki"
Link to this function

build(value1, value2, value3)

View Source

Specs

build(term(), term(), term()) :: String.t()

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

iex> Miss.String.build("akira", "hamasaki", "123")
"akirahamasaki123"

iex> Miss.String.build(:akira, 'hamasaki', 123)
"akirahamasaki123"
Link to this function

build(value1, value2, value3, value4)

View Source

Specs

build(term(), term(), term(), term()) :: String.t()

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

iex> Miss.String.build("akira", "hamasaki", "123", "pim")
"akirahamasaki123pim"

iex> Miss.String.build(:akira, 'hamasaki', 123, [112, 105, 109])
"akirahamasaki123pim"
Link to this function

build(value1, value2, value3, value4, value5)

View Source

Specs

build(term(), term(), term(), term(), term()) :: String.t()

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

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"