asObject               package:Matrix               R Documentation

_A_s_s_i_g_n _o_r _M_o_d_i_f_y _t_h_e _C_l_a_s_s _o_f _a_n _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     `asObject' assigns a class to an object and returns the object.
     `prependClass' prepends a class to the set of classes for an
     object and returns the object.

_U_s_a_g_e:

     asObject(x, cl)
     prependClass(x, cl)

_A_r_g_u_m_e_n_t_s:

       x: an object.

      cl: a character vector of classes.

_D_e_t_a_i_l_s:

     `asObject' is simply a wrapper for the sequence `class(x) <- cl;
     x'.  Its main use is in constructing the value that a function
     will return.   It differs from the assignment `class(x) <- cl' in
     that the assignment returns the class whereas `asObject' returns
     the object with the class.

     `prependClass' is a similar function that extends the classes (if
     any) of the object and returns the object.

_V_a_l_u_e:

     the object `x' with the class `cl' (or `c(cl, class(x))' for
     `prependClass').

_E_x_a_m_p_l_e_s:

     x <- asObject(3, "myClass")
     print.default(x)
     print.default(prependClass(x, "firstClass"))

