ubill

ubill

Iex Shell: How to delete/overwrite an alias in the shell?

I have asked this question on Slack, no solutions from there, so putting it up here.

The situation is,

Let’s say I’ve typed in the iex shell alias Asdf.Qwer, but actually what I need now is simply Qwer , I have no way to clear Asdf.Qwer because alias Qwer just again gives me Asdf.Qwer . So am I forever stuck with that? Or is there a way to reset/delete aliases

In other words, Qwer is now forever referring to Asdf.Qwer because of my mistype, and there is no way to delete/say that I don’t want this anymore. Or is there?

(P.S. an unrelated question, is the source code of Elixir Forum available as open source somewhere? It’s a great interface and I admire it very much.)

Marked As Solved

Also Liked

bobbypriambodo

bobbypriambodo

Hmm, funny, it seems that you can overwrite alias in some cases and can’t in other cases. I’ve played with this:

iex> alias Asdf.Qwer
Asdf.Qwer
iex> Qwer
Asdf.Qwer

# still not working
iex> alias Qwer
Asdf.Qwer
iex> alias Qwer, as: Qwer
Asdf.Qwer

# this works?
iex> alias Foo, as: Qwer
Foo
iex> Qwer
Foo

# this also works
iex> alias Bar.Qwer
Bar.Qwer
iex> Qwer
Bar.Qwer

# funnily, this seemed to work at first glance (but really doesn't)
iex> alias Elixir.Qwer
Qwer # refers Qwer, yeay!
iex> Qwer
Bar.Qwer # it reverts, the alias doesn't work.
josevalim

josevalim

Creator of Elixir

This is a bug. Can you please file a bug report?

bobbypriambodo

bobbypriambodo

Is closing and reopening the shell (or via respawn) not a viable solution? (basically it will clear all bound variables and aliases in the shell.)

muhifauzan

muhifauzan

Since you use alias which is alias Asdf.Qwer, you can refer to the original Qwer using Elixir. Call it like this Elixir.Qwer.

muhifauzan

muhifauzan

Yeah, I can confirm this. I also just playing around with alias in IEx with the same result as yours.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement