Kin
Sigil_r example not working as shown in the official docs
I am following the elixir official docs and on the sigil page here https://elixir-lang.org/getting-started/sigils.html#custom-sigils
this example:
sigil_r(<<"foo">>, ~c"i")
is not working for me. The output should be
~r"foo"i
but it is:
iex(48)> sigil_r(<<"foo">>, ~c"i")
** (ArgumentError) errors were found at the given arguments:
* 1st argument: not an iodata term
(stdlib 5.0.2) :binary.list_to_bin({:sigil_c, [delimiter: "\"", line: 48], [{:<<>>, [line: 48], ["i"]}, []]})
(elixir 1.15.5) expanding macro: Kernel.sigil_r/2
iex:48: (file)
Marked As Solved
josevalim
Creator of Elixir
You are right, it should be:
sigil_r(<<"foo">>, [?i])
Would you like to submit a PR to the docs or shall I update it?
4
Also Liked
Nicd
Looks like it works with the old charlist syntax but not with the new:
iex(1)> sigil_r(<<"foo">>, 'i')
~r/foo/i
iex(2)> sigil_r(<<"foo">>, ~c"i")
** (ArgumentError) errors were found at the given arguments:
* 1st argument: not an iodata term
(stdlib 5.1.1) :binary.list_to_bin({:sigil_c, [delimiter: "\"", line: 2], [{:<<>>, [line: 2], ["i"]}, []]})
(elixir 1.15.6) expanding macro: Kernel.sigil_r/2
iex:2: (file)
I guess the syntax has been changed to the new one without checking if it works. Filing an issue here could be a good starting point: GitHub - elixir-lang/elixir-lang.github.com: Website for Elixir · GitHub
2
Last Post!
Kin
Popular in Questions
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
Other popular topics
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









