ArrayRecord

com.github.tarao.record4s.ArrayRecord
See theArrayRecord companion class
object ArrayRecord extends Extensible[EmptyTuple], ArrayRecordPlatformSpecific

Attributes

Companion
class
Source
ArrayRecord.scala
Graph
Supertypes
trait Extensible[EmptyTuple]
trait Dynamic
class Object
trait Matchable
class Any
Show all
Self type

Members list

Type members

Classlikes

object Extensible

Attributes

Companion
trait
Source
ArrayRecord.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Extensible.type
trait Extensible[R] extends Dynamic

Attributes

Companion
object
Source
ArrayRecord.scala
Supertypes
trait Dynamic
class Any
Known subtypes
class Appender[R]
object ArrayRecord
final implicit class OpsCompat[R](record: ArrayRecord[R]) extends AnyVal

Attributes

Source
ArrayRecord.scala
Supertypes
class AnyVal
trait Matchable
class Any
final class RecordLikeArrayRecord[R] extends RecordLike[ArrayRecord[R]]

Attributes

Source
ArrayRecord.scala
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

inline def from[T : RecordLike, RR <: ProductRecord](x: T)(implicit evidence$1: RecordLike[T], Aux[T, RR]): RR

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
inline def lookup[R, L <: String & Singleton, Index <: Int, Out](record: ArrayRecord[R], label: L)(using Aux[R, L, Index, Out]): Out

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

transparent inline def applyDynamic(method: String)(inline fields: Any*): Any

Attributes

Inherited from:
Extensible
Source
ArrayRecord.scala
transparent inline def applyDynamicNamed(method: String)(inline fields: (String, Any)*): Any

Attributes

Inherited from:
Extensible
Source
ArrayRecord.scala
def fromJS[T <: Tuple](obj: Any)(using nc: NativeConverter[ArrayRecord[T]]): ArrayRecord[T]

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
def fromJSON[T <: Tuple](json: String)(using nc: NativeConverter[ArrayRecord[T]]): ArrayRecord[T]

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

val empty: ArrayRecord[EmptyTuple]

An empty record

An empty record

Attributes

Source
ArrayRecord.scala

Givens

Givens

given canEqualReflexive[R]: CanEqual[ArrayRecord[R], ArrayRecord[R]]

Attributes

Source
ArrayRecord.scala
transparent inline given recordLike[R]: RecordLike[ArrayRecord[R]]

Attributes

Source
ArrayRecord.scala

Inherited givens

inline given nativeConverter[R]: NativeConverter[ArrayRecord[R]]

Extensions

Extensions

extension [R](record: ArrayRecord[R])
inline def +: Extensible[R]

Alias for updated

Alias for updated

Attributes

Source
ArrayRecord.scala
inline def ++[R2 : RecordLike, RR <: ProductRecord](other: R2)(implicit evidence$1: RecordLike[R2], c: Concat[R, R2]): c.Out

Alias for concat

Alias for concat

Attributes

Source
ArrayRecord.scala
inline def concat[R2 : RecordLike, RR <: ProductRecord](other: R2)(implicit evidence$1: RecordLike[R2], c: Concat[R, R2]): c.Out

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
def tag[T]: ArrayRecord[R & Tag[T]]

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
inline def toRecord[RR <: %](using Aux[ArrayRecord[R], RR]): RR

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
inline def toTuple(using r: RecordLike[ArrayRecord[R]], conv: Converter[ArrayRecord[R], r.ElemTypes]): Zip[r.ElemLabels, r.ElemTypes]

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
transparent inline def upcast[R2]: Any

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

extension [R](record: ArrayRecord[R])
def toJS(using NativeConverter[ArrayRecord[R]]): Any

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
def toJSON(using NativeConverter[ArrayRecord[R]]): String

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

final implicit def OpsCompat[R](record: ArrayRecord[R]): OpsCompat[R]

Attributes

Source
ArrayRecord.scala