Learn R Programming

sicher (version 0.1.0)

[.sicher_type: Vector Size Operator for sicher_type

Description

Creates a type that checks for a specific vector length.

Usage

# S3 method for sicher_type
[(type, size)

Value

A new sicher_type that checks for the specified length

Arguments

type

A sicher_type object

size

The required length (non-negative integer)

Examples

Run this code
vec %:% Numeric[3] %<-% c(1, 2, 3)
try(vec <- c(1, 2)) # Error: wrong length
try(vec <- c("a", "b", "c"))  # Error: wrong type

Run the code above in your browser using DataLab