“!”,“?”,“ _”和“。”的含义是什么。长生不老药中的语法 [英] What's the meaning of "!", "?", "_", and "." syntax in elixir

查看:242
本文介绍了“!”,“?”,“ _”和“。”的含义是什么。长生不老药中的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助来了解lix剂 _中的以下语法
elixir功能中的那些语法角色是什么?例如 Repo.get!

I need help regarding understanding the following syntaxes in elixir !, ?, _, and .. What's those syntaxes role in elixir's function? For example Repo.get!.

我不确定它们只是函数名还是带有角色。虽然我知道用于调用匿名函数。而 _ 是任意字符还是可变参数?

I'm not sure whether they were just function name, or has a role. Though I know . is for calling anonymous function. And _ for any or variadic?

推荐答案

-引发故障异常的函数的约定。

! - Convention for functions which raise exceptions on failure.

-约定对于返回布尔值的函数

? - Convention for functions which return a boolean value

_ -用于忽略参数或模式匹配表达式的一部分。

_ - Used to ignore an argument or part of a pattern match expression.

-如前所述,它用于调用匿名函数,但也用于访问模块函数例如 Mod.a(arg)

. - As you mentioned is used for calling an anonymous function, but is also used for accessing a module function such as Mod.a(arg).

这篇关于“!”,“?”,“ _”和“。”的含义是什么。长生不老药中的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆