Proposal: String.swapcase/1 & String.center/2 & String.center/3

60 views
Skip to first unread message

Dunya Kirkali

unread,
Jan 27, 2018, 6:15:12 AM1/27/18
to elixir-lang-core
Hi,

I would like to propose to introduce a `swapcase/1` function to the `Sting` module.

Lately I have been rewriting some of my old Ruby code in Elixir and have realized that some of the handy String functions from Ruby were not yet there in Elixir.
So I wrote a module to achieve those. But I thought since such functions are already in core Ruby that maybe we would also like to have them in Elixir.

It's obviously not a must have. I'd be happy to prepare a PR if accepted!

Dunya Kirkali

unread,
Jan 27, 2018, 6:16:27 AM1/27/18
to elixir-lang-core
A small Edit:

I would like to propose to introduce a `swapcase/1`, `center/2` & `center/3` functions to the `Sting` module.

Louis Pilfold

unread,
Jan 27, 2018, 6:44:58 AM1/27/18
to elixir-lang-core

Hi Dunya

What would these functions do?

Cheers,
Louis


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/c2bda818-9913-4834-84c0-00fe40178bd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dunya Kirkali

unread,
Jan 27, 2018, 6:51:50 AM1/27/18
to elixir-lang-core
Similar to their Ruby equivalents:

# String.swapcase/1
"hELLO" = Tanga.swapcase("Hello")
# String.center/2
"       hello        " = String.center("hello", 20)
# String.center/3
"~~~~~~~hello~~~~~~~~~" = String.center("hello", 20, "~")

Dunya Kirkali

unread,
Jan 28, 2018, 4:20:04 PM1/28/18
to elixir-lang-core
Reply all
Reply to author
Forward
0 new messages