3
votes

I am new to elixir and was going through sample chat application written in it using phoenix framework. I am not able to understand meaning of this line

channel "rooms:*", Chat.RoomChannel

I searched online for this type of syntax but could not got the answer I was looking for. I know that Chat.RoomChannel is a module and channel follows a string which identifies type of room under consideration

I want to know how that syntax works

1
This is equivalent to channel("rooms:*", Chat.RoomChannel) which may look more familiar to you. The parens are optional.Chris Martin
Got it! thnx @ChrisMartin :)Kelsadita

1 Answers

5
votes

The comma seperates the argument list.

I guess you are getting confused that this is a function call. In elixir when calling a function its optional to give paranthesis. So

channel "rooms:*", Chat.RoomChannel

Is equivalent to

channel("rooms:*", Chat.RoomChannel)