This topic created in 2559 days ago, the information mentioned may be changed or developed.
在 Object 类下面添加一个函数,比如说
void print(){
System.out.println(this); //js c#类似
}
这样不是方面更多了吗,lambda 更简洁,还可以链式调用
"hello world". print ()
有没有语言是这样的
7 replies • 2019-06-08 18:17:36 +08:00
 |
|
1
runze Jun 7, 2019 via Android
powershell?
|
 |
|
2
kaneg Jun 7, 2019 via iPhone
System.out 输出在稍大点的项目中都是禁止的,在 Object 这么基础的类中加这个是大材小用了
|
 |
|
3
WispZhan Jun 7, 2019
随便一个支持"Extension Functions"的语言都没这个烦恼。
|
 |
|
4
shiroikuma Jun 7, 2019 via Android
@ kaneg 调试也很重要呐。能把 print 写进预置函数,为啥不能写进 object
|
 |
|
6
luozic Jun 7, 2019 via iPhone
支持管道的语言,直接把栈里面的输出到管道不是更容易调试? 要么就直接上全局 tracid。
|
 |
|
7
temp178 Jun 8, 2019 via Android
Object 类作为对象的父类,它的方法应该是和 对象 这个概念相关的,如 toString , hashcode,equals 等,而不是和业务相关的 print
|