首页 > 其他 > 详细

弱类型、强类型、动态类型、静态类型

时间:2017-08-10 11:11:30      阅读:217      评论:0      收藏:0      [点我收藏+]

装载: https://www.zhihu.com/question/19918532

 

弱类型:
> "1"+2
12
 
强类型:
>>> "1"+2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot concatenate str and int objects
 
动态类型:
>>> a = 1
>>> type(a)
<type int>
>>> a = "s"
>>> type(a)
<type str>
 
静态类型:
Prelude> let a = "123" :: Int

<interactive>:2:9:
    Couldnt match expected type `Int with actual type `[Char]    In the expression: "123" :: Int
    In an equation for `a: a = "123" :: Int
 
技术分享

 

 

弱类型、强类型、动态类型、静态类型

原文:http://www.cnblogs.com/bincoding/p/7337983.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!