What is the "<>" operator called in Elixir?
Michael Lee 🍕

Michael Lee 🍕 @michael

About: Maker of things, giver of high-fives 🖐

Location:
Cary, NC
Joined:
Apr 14, 2017

What is the "<>" operator called in Elixir?

Publish Date: Sep 6 '19
8 6

I'm reading over the Elixir guides and recently came across the various operators. One of which is the <> operator used to concatenate two stings. It doesn't mention a name for the operator though. And it's my first time seeing that in any language.

"Hello" <> " World"
"Hello World"
Enter fullscreen mode Exit fullscreen mode

Comments 6 total

  • Ben Lovy
    Ben LovySep 6, 2019

    In my head I just call it the "string concatenation operator", I've also never seen any official name for it. I don't believe it's used for anything else.

    • Michael Lee 🍕
      Michael Lee 🍕Sep 6, 2019

      Yeah, I figured it's more of a symbol to represent a function or utility to do something. Just wasn't sure if it had a name. Looking over the doc I realized there's a lot of other symbols used to do things but don't actually have names such as ++ use to combine lists.

      Think I'll probably be calling it that in my head as well :)

  • Robin Palotai
    Robin PalotaiSep 6, 2019

    In Haskell, this would be called "mappend", for Monoid append.

    (Actually it's Semigroup append, but don't let that bother you)

  • Eljay-Adobe
    Eljay-AdobeSep 6, 2019

    I'd call <> the "concatenation operator" or "string concatenation operator", which is what the Elixir documentation refers to it as.

    If speaking causally, I might call it "cat", "concat", or "join".

    • Michael Lee 🍕
      Michael Lee 🍕Sep 6, 2019

      Makes sense. The docs seems to use symbols to describe how to do something versus the need to name everything. Looking over the doc I noticed other things such as ++ to combine lists. I suppose you could infer that it's called plus plus but really the symbol is used to describe what it does.

Add comment