由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 捏着鼻子看scala b编程pattern
相关主题
Java Streams vs C# LINQ vs Java6当年twtr用ruby 最后还是dump了 Scala会不会下场一样
用scala 算一个东西, out of memory 了,怎么办?最近比较闲,想学下FP,
推荐一本书: The Well-Grounded Java Developer阅读scala中
Java EE这东西还有必要学吗狂搞swift中
akka/scala/jvmscala的type system太复杂了
Scala这次又被比下去了入了一本java8后悔了
Java 8 闪亮发布了spark 为啥不用 java 写
谈谈为什么上scala有几个人能 背着把gof 23种pattern 用java 随便写5,6个写出来
相关话题的讨论汇总
话题: int话题: class话题: case话题: string话题: pattern
进入Programming版参与讨论
1 (共1页)
d******e
发帖数: 2265
1
You’re working with match expressions, actors, or other situations where
you want to use the case class syntax to generate boilerplate code,
including accessor and mutator methods, along with apply, unapply, toString,
equals, and hashCode methods, and more.
Solution
Define your class as a case class, defining any parameters it needs in its
constructor:
// name and relation are 'val' by default
case class Person(name: String, relation: String)
case class UsersBreakdown(nbUsers: Int, active: Int, waiting: Int, done: Int)
这个恶心程度赶上c++了。就为了 apply, tostirng, equals, hashcode 的默认实现。
l******t
发帖数: 55733
2
很好啊
p*****2
发帖数: 21240
3
这个东西太牛逼了

toString,
Int)

【在 d******e 的大作中提到】
: You’re working with match expressions, actors, or other situations where
: you want to use the case class syntax to generate boilerplate code,
: including accessor and mutator methods, along with apply, unapply, toString,
: equals, and hashCode methods, and more.
: Solution
: Define your class as a case class, defining any parameters it needs in its
: constructor:
: // name and relation are 'val' by default
: case class Person(name: String, relation: String)
: case class UsersBreakdown(nbUsers: Int, active: Int, waiting: Int, done: Int)

l**********n
发帖数: 8443
4
这个要怪Java

toString,
Int)

【在 d******e 的大作中提到】
: You’re working with match expressions, actors, or other situations where
: you want to use the case class syntax to generate boilerplate code,
: including accessor and mutator methods, along with apply, unapply, toString,
: equals, and hashCode methods, and more.
: Solution
: Define your class as a case class, defining any parameters it needs in its
: constructor:
: // name and relation are 'val' by default
: case class Person(name: String, relation: String)
: case class UsersBreakdown(nbUsers: Int, active: Int, waiting: Int, done: Int)

d******e
发帖数: 2265
5
准备看看能不能见个alias这个太别扭了

【在 p*****2 的大作中提到】
: 这个东西太牛逼了
:
: toString,
: Int)

g*****g
发帖数: 34805
6
With defined fields, a java bean is a few clicks away to generate these
functions in a modern day IDE, probably taking less time to write than a
case class in Scala.
I am not denying Java is more verbose, but it also offers more flexibility,
like sometimes you want to override setter.

【在 l**********n 的大作中提到】
: 这个要怪Java
:
: toString,
: Int)

p*****2
发帖数: 21240
7

,
这个主要是为了pattern matching。Java8也没提供这个功能。

【在 g*****g 的大作中提到】
: With defined fields, a java bean is a few clicks away to generate these
: functions in a modern day IDE, probably taking less time to write than a
: case class in Scala.
: I am not denying Java is more verbose, but it also offers more flexibility,
: like sometimes you want to override setter.

x***4
发帖数: 1815
8
有道理。case class就是为了和match一起用。

【在 p*****2 的大作中提到】
:
: ,
: 这个主要是为了pattern matching。Java8也没提供这个功能。

c******f
发帖数: 243
9
碰到过类似东西...特意用java写了个builder.
l******t
发帖数: 55733
10
不止。method应该进trait。case class就纯data

【在 x***4 的大作中提到】
: 有道理。case class就是为了和match一起用。
相关主题
Scala这次又被比下去了当年twtr用ruby 最后还是dump了 Scala会不会下场一样
Java 8 闪亮发布了最近比较闲,想学下FP,
谈谈为什么上scala阅读scala中
进入Programming版参与讨论
g*****g
发帖数: 34805
11
Pattern matching is a rarely used feature at best. If you downcast a lot,
the design must be wrong.

【在 p*****2 的大作中提到】
:
: ,
: 这个主要是为了pattern matching。Java8也没提供这个功能。

p*****2
发帖数: 21240
12
没有pm java 用akka很痛苦吧?

【在 g*****g 的大作中提到】
: Pattern matching is a rarely used feature at best. If you downcast a lot,
: the design must be wrong.

p*****2
发帖数: 21240
13
不止 还要immutable

【在 l******t 的大作中提到】
: 不止。method应该进trait。case class就纯data
l******t
发帖数: 55733
14



【在 p*****2 的大作中提到】
: 不止 还要immutable
c*******9
发帖数: 9032
15
做framework,工具软件的会常用。

【在 g*****g 的大作中提到】
: Pattern matching is a rarely used feature at best. If you downcast a lot,
: the design must be wrong.

1 (共1页)
进入Programming版参与讨论
相关主题
有几个人能 背着把gof 23种pattern 用java 随便写5,6个写出来akka/scala/jvm
L家不再用scala了。。Scala这次又被比下去了
Scala in LJava 8 闪亮发布了
我还是认为scala的程序员水平高谈谈为什么上scala
Java Streams vs C# LINQ vs Java6当年twtr用ruby 最后还是dump了 Scala会不会下场一样
用scala 算一个东西, out of memory 了,怎么办?最近比较闲,想学下FP,
推荐一本书: The Well-Grounded Java Developer阅读scala中
Java EE这东西还有必要学吗狂搞swift中
相关话题的讨论汇总
话题: int话题: class话题: case话题: string话题: pattern