ruby elixir_将Elixir与ruby和javascript语法进行比较

ruby elixir

I have been writing Elixir full-time for about a year, but I came to it from Ruby. As you probably know, Elixir was created by a former Ruby developer, José Valim, and his idea was to keep the beautiful syntax of Ruby in Elixir.

我一直在专职撰写Elixir,但我是从Ruby来的。 您可能知道,Elixir由前Ruby开发人员JoséValim创建,他的想法是将Ruby的漂亮语法保留在Elixir中。

In the company I currently work for, we created an Elixir School to help other colleagues start developing in Elixir. They’re mainly Ruby developers, but also some front-end developers want to study it.

在我目前工作的公司中,我们创建了一家Elixir学校,以帮助其他同事开始在Elixir中发展。 他们主要是Ruby开发人员,但也有一些前端开发人员想要研究它。

For one of the lessons, I created slides with a syntax comparison of Elixir, Ruby, and JavaScript. In this article, I would like to share that with you.

对于其中一课,我创建了具有Elixir,Ruby和JavaScript语法比较的幻灯片。 在本文中,我想与您分享。

(String)

Image for post

原子 (Atom)

Image for post

布尔型 (Boolean)

Image for post

列表与元组 (List vs Tuple)

Lists are stored in memory as linked lists, meaning that each element in a list holds its value and points to the following element until the end of the list is reached. This means accessing the length of a list is a linear operation: we need to traverse the whole list in order to figure out its size.

列表以链接列表的形式存储在内存中,这意味着列表中的每个元素都保留其值并指向下一个元素,直到到达列表的末尾。 这意味着访问列表的长度是线性操作:我们需要遍历整个列表才能确定其大小。

You will find a good explanation in AppSignal article about this, I highly recommend you read it, as it is important to understand.

您将在AppSignal文章中找到关于此的很好的解释,我强烈建议您阅读它,因为它很重要。

地图 (Map)

Image for post

(Nil)

Image for post

插补 (Interpolation)

Image for post

串联字符串 (Concatenation String)

Image for post

串联列表 (Concatenation List)

Image for post

范围 (Range)

Image for post

If语句和三元运算符 (If statement and Ternary operator)

Image for post
Image for post
Image for post

案例陈述 (Case Statement)

Image for post
Image for post
Image for post

管道操作员 (Pipe Operator)

Image for post

理解 (Comprehension)

Image for post

匿名函数 (Anonymous Function)

Image for post

定义模块和功能 (Define Module and Function)

Image for post
Image for post
* Modules aren't available in JS, such that this example shows a class to have some analogy.
*模块在JS中不可用,因此此示例显示了一个具有类推性的类。
Image for post

All slides you can be found on my speaker deck.

您可以在我的扬声器甲板上找到所有的幻灯片。

Image for post

翻译自: https://medium.com/better-programming/compare-elixir-with-ruby-and-javascript-syntax-61cf599f262d

ruby elixir

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值