zoukankan      html  css  js  c++  java
  • LYSE-类型

    动态强类型

    在运行时捕捉所有错误。

    多数语言的目标是做到没有错误,而Erlang假设错误会发生因此要覆盖所有错误。

    强类型,不会进行隐式的类型转换。

    类型转换

    使用erlang模块的内建函数  

    1> erlang:list_to_integer("54").
    54
    2> erlang:integer_to_list(54).
    "54"
    3> erlang:list_to_integer("54.32").
    ** exception error: bad argument
    in function  list_to_integer/1
    called as list_to_integer("54.32")
    4> erlang:list_to_float("54.32").
    54.32
    5> erlang:atom_to_list(true).
    "true"
    6> erlang:list_to_bitstring("hi there").
    <<"hi there">>
    7> erlang:bitstring_to_list(<<"hi there">>).
    "hi there"

    守护数据类型

    is_atom/1           is_binary/1        
    is_bitstring/1      is_boolean/1        is_builtin/3       
    is_float/1          is_function/1       is_function/2      
    is_integer/1        is_list/1           is_number/1        
    is_pid/1            is_port/1           is_record/2        
    is_record/3         is_reference/1      is_tuple/1 

    Erlang设计为给正确的范例编程。

    守护表达式使用的其它BIFs:

    abs(Number), bit_size(Bitstring), byte_size(Bitstring), element(N, Tuple), float(Term), hd(List), length(List), node(), node(Pid|Ref|Port), round(Number), self(), size(Tuple|Bitstring), tl(List), trunc(Number), tuple_size(Tuple).
  • 相关阅读:
    springboot中添加自定义filter
    一台电脑同时运行多个tomcat配置方法:
    web 后台数据交互的方式
    xml
    开发互联网应用与开发企业级应用有什么异同
    新学期目标
    换了呗项目总结
    换了呗项目
    黄金点游戏
    自我介绍
  • 原文地址:https://www.cnblogs.com/sqxy110/p/4997079.html
Copyright © 2011-2022 走看看