Attributes
- Companion
- class
- Source
- ArrayRecord.scala
- Graph
-
- Supertypes
- Self type
-
ArrayRecord.type
Members list
Type members
Classlikes
Attributes
- Companion
- trait
- Source
- ArrayRecord.scala
- Supertypes
- Self type
-
Extensible.type
Attributes
- Companion
- object
- Source
- ArrayRecord.scala
- Supertypes
-
trait Dynamicclass Any
- Known subtypes
-
class Appender[R]object ArrayRecord
Attributes
- Source
- ArrayRecord.scala
- Supertypes
-
class AnyValtrait Matchableclass Any
Attributes
- Source
- ArrayRecord.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 = ArrayRecord.from(p) // val r: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
- Source
- ArrayRecord.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 ArrayRecord
.
Value parameters
- label
-
a string literal field name
- record
-
a record
Attributes
- Returns
-
the value of the field named by
label
- Example
-
val r = ArrayRecord(value = 3, toString = 10) r.value // val res0: Int = 3 r.toString // val res1: String = ArrayRecord(value = 3, toString = 10) ArrayRecord.lookup(r, "value") // val res2: Int = 3 ArrayRecord.lookup(r, "toString") // val res3: Int = 10
- Source
- ArrayRecord.scala
Inherited methods
Attributes
- Inherited from:
- Extensible
- Source
- ArrayRecord.scala
Attributes
- Inherited from:
- Extensible
- Source
- ArrayRecord.scala
Construct an array record from a JavaScript object.
Construct an array record from a JavaScript object.
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
This operation is of course unsafe. Missing primitive fields become zeros or nulls and missing object fields yield java.lang.RuntimeException
.
Value parameters
- nc
-
a conversion type class
- obj
-
a JavaScript object
Attributes
- Returns
-
an array record
- Example
-
import scala.scalajs.js val obj: js.Any = js.Dynamic.literal(name = "tarao", age = 3) val r = ArrayRecord.fromJS[(("name", String), ("age", Int))](obj) // val r: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
- Inherited from:
- ArrayRecordPlatformSpecific
- Source
- ArrayRecordPlatformSpecific.scala
Construct an array record from a JSON string.
Construct an array record from a JSON string.
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
This operation is of course unsafe. Missing primitive fields become zeros or nulls and missing object fields yield java.lang.RuntimeException
.
Value parameters
- json
-
a JSON string
- nc
-
a conversion type class
Attributes
- Returns
-
an array record
- Example
-
import scala.scalajs.js val json = """{"name":"tarao","age":3}""" val r = ArrayRecord.fromJSON[(("name", String), ("age", Int))](json) // val r: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
- Inherited from:
- ArrayRecordPlatformSpecific
- Source
- ArrayRecordPlatformSpecific.scala
Concrete fields
An empty record
Givens
Inherited givens
Attributes
- Inherited from:
- ArrayRecordPlatformSpecific
- Source
- ArrayRecordPlatformSpecific.scala
Extensions
Extensions
Alias for updated
Alias for concat
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 = ArrayRecord(name = "tarao", age = 3) val r2 = ArrayRecord(age = 4, email = "[email protected]") val r3 = r1 ++ r2 // val r3: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int), ("email", String))] = ArrayRecord(name = tarao, age = 4, email = [email protected])
- Source
- ArrayRecord.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 [T <: Tuple](p: ArrayRecord[(("name", String) *: T) & Tag[Person]]) { def firstName: String = p.name.split(" ").head } } val r = ArrayRecord(name = "tarao fuguta", age = 3).tag[Person] r.firstName // val res0: String = tarao
- Source
- ArrayRecord.scala
Convert to a record of type %
.
Convert to a record of type %
.
Attributes
- Returns
-
a record of type
%
- Example
-
val r1 = ArrayRecord(name = "tarao", age = 3) // val r1: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3) r1.toRecord // val res0: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
- Source
- ArrayRecord.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 = ArrayRecord(name = "tarao", age = 3) r1.toTuple // val res0: (("name", String), ("age", Int)) = ((name,tarao),(age,3))
- Source
- ArrayRecord.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 = ArrayRecord(name = "tarao", age = 3, email = "[email protected]") // val r1: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int), ("email", String))] = ArrayRecord(name = tarao, age = 3, email = [email protected]) val r2 = r1.upcast[(("name", String), ("age", Int))] // val r2: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int))] = ArrayRecord(name = tarao, age = 3)
- Source
- ArrayRecord.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 = ArrayRecord(name = "tarao") + (age = 3, email = "[email protected]") // val r: com.github.tarao.record4s.ArrayRecord[(("name", String), ("age", Int), ("email", String))] = ArrayRecord(name = tarao, age = 3, email = [email protected])
- Source
- ArrayRecord.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 = ArrayRecord(name = "tarao", age = 3) r1.values // val res0: (String, Int) = (tarao,3)
- Source
- ArrayRecord.scala
Inherited extensions
Convert this array record to a JavaScript object
Convert this array record to a JavaScript object
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
Attributes
- Returns
-
a JavaScript object
- Example
-
val r = ArrayRecord(name = "tarao", age = 3) val obj = r.toJS // val obj: scala.scalajs.js.Any = [object Object]
- Inherited from:
- ArrayRecordPlatformSpecific
- Source
- ArrayRecordPlatformSpecific.scala
Convert this array record to a JSON string
Convert this array record to a JSON string
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
Attributes
- Returns
-
a JSON string
- Example
-
val r = ArrayRecord(name = "tarao", age = 3) val json = r.toJSON // val json: String = {"name":"tarao","age":3}
- Inherited from:
- ArrayRecordPlatformSpecific
- Source
- ArrayRecordPlatformSpecific.scala
Implicits
Implicits
Attributes
- Source
- ArrayRecord.scala