Attributes
- Companion
- trait
- Source
- Record.scala
- Graph
-
- Supertypes
- Self type
-
Record.type
Members list
Type members
Classlikes
Attributes
- Source
- Record.scala
- Supertypes
-
trait Dynamicclass AnyValtrait Matchableclass Any
Attributes
- Source
- Record.scala
- Supertypes
Value members
Concrete methods
Construct a record from something else.
Construct a record from something else.
Type parameters
- T
-
some type given
RecordLike[T]
Value parameters
- x
-
something that is record like
Attributes
- Returns
-
a record
- Example
-
case class Person(name: String, age: Int) val p = Person("tarao", 3) val r = Record.from(p) // val r: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
- Source
- Record.scala
Get the field value of specified label.
Get the field value of specified label.
It is essentially the same as record.{label}
but it can access to fields hidden by own methods of class %
.
Value parameters
- label
-
a string literal field name
- record
-
a record
Attributes
- Returns
-
the value of the field named by
label
- Example
-
val r = %(value = 3, toString = 10) r.value // val res0: Int = 3 r.toString // val res1: String = %(value = 3, toString = 10) Record.lookup(r, "value") // val res2: Int = 3 Record.lookup(r, "toString") // val res3: Int = 10
- Source
- Record.scala
Concrete fields
An empty record.
Givens
Extensions
Extensions
Alias for updated
Alias for concat
Create a new record by selecting some fields of an existing record.
Create a new record by selecting some fields of an existing record.
Type parameters
- RR
-
type of the new record
- S
-
list of selected field as a Tuple
Value parameters
- s
-
selection of fields created by
select
Attributes
- Returns
-
a new record with the selected fields
- Example
-
val r1 = %(name = "tarao", age = 3, email = "[email protected]") val r2 = r1(select.name.age) // val r2: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3) val r3 = r1(select.name(rename = "nickname").age) // val r3: com.github.tarao.record4s.%{val nickname: String; val age: Int} = %(nickname = tarao, age = 3)
- Source
- Record.scala
Create a new record by unselecting some fields of an existing record.
Create a new record by unselecting some fields of an existing record.
Type parameters
- RR
-
type of the new record
- U
-
list of unselected field as a Tuple
Value parameters
- u
-
unselection of fields created by
unselect
Attributes
- Returns
-
a new record without the unselected fields
- Example
-
val r1 = %(name = "tarao", age = 3, email = "[email protected]") val r2 = r1(unselect.email) // val r2: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
- Source
- Record.scala
Upcast the record to specified type.
Upcast the record to specified type.
Type parameters
- R2
-
target type
Attributes
- Returns
-
a record containing only fields in the target type
- Example
-
val r1 = %(name = "tarao", age = 3, email = "[email protected]") // val r1: com.github.tarao.record4s.%{val name: String; val age: Int; val email: String} = %(name = tarao, age = 3, email = [email protected]) val r2 = r1.as[% { val name: String; val age: Int }] // val r2: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
- Source
- Record.scala
Concatenate this record and another record.
Concatenate this record and another record.
If the both record has a field of the same name, then it takes the field from the latter record.
Type parameters
- R2
-
a record type (given
RecordLike[R2]
)
Value parameters
- other
-
a record to concatenate
Attributes
- Returns
-
a new record which has the both fields from this record and
other
- Example
-
val r1 = %(name = "tarao", age = 3) val r2 = %(age = 4, email = "[email protected]") val r3 = r1 ++ r2 // val r3: com.github.tarao.record4s.%{val name: String; val age: Int; val email: String} = %(name = tarao, age = 4, email = [email protected])
- Source
- Record.scala
Give a type tag to this record.
Give a type tag to this record.
Type parameters
- T
-
an arbitrary type used as a tag
Attributes
- Returns
-
the same record with a tag type
- Example
-
trait Person; object Person { extension (p: %{val name: String} & Tag[Person]) { def firstName: String = p.name.split(" ").head } } val r = %(name = "tarao fuguta", age = 3).tag[Person] r.firstName // val res0: String = tarao
- Source
- Record.scala
Convert this record to a To
.
Convert this record to a To
.
Type parameters
- To
-
a type to which the record is converted
Attributes
- Returns
-
a new product instance
- Example
-
case class Person(name: String, age: Int) val r = %(name = "tarao", age = 3) r.to[Person] // val res0: Person = Person(tarao,3)
- Source
- Record.scala
Convert this record to a Tuple
.
Convert this record to a Tuple
.
Attributes
- Returns
-
fields of label-value pairs as a tuple
- Example
-
val r1 = %(name = "tarao", age = 3) r1.toTuple // val res0: (("name", String), ("age", Int)) = ((name,tarao),(age,3))
- Source
- Record.scala
Extend the record by fields.
Extend the record by fields.
If a new field has the same name as the existing field, then the new field overrides the old one.
Attributes
- Returns
-
an object to define new fields
- Example
-
val r = %(name = "tarao") + (age = 3, email = "[email protected]") // val r: com.github.tarao.record4s.%{val name: String; val age: Int; val email: String} = %(name = tarao, age = 3, email = [email protected])
- Source
- Record.scala
Return values of this record as a Tuple
.
Return values of this record as a Tuple
.
Attributes
- Returns
-
values of the record as a tuple
- Example
-
val r1 = %(name = "tarao", age = 3) r1.values // val res0: (String, Int) = (tarao,3)
- Source
- Record.scala