Hi
I'd just found the following peculiarity in Mata when passing string colvector or vector arguments to functions (This is done in Stata 14):
Inside function test I define an empty string colvector v and validates that this is true.
Then I add a row, and now is the orgtype a scalar instead, however it got 1 row and 1 column.
How can that be? What have I done wrong?
I'd just found the following peculiarity in Mata when passing string colvector or vector arguments to functions (This is done in Stata 14):
Code:
: function test() { > string colvector v > v = J(0,1,"") // Empty start value > eltype(v), orgtype(v) // Validate before > rows(v), cols(v) // Validate before > v = v \ "add row value" > eltype(v), orgtype(v) // Validate after > rows(v), cols(v) // Validate after > } : test() 1 2 +-------------------------+ 1 | string colvector | +-------------------------+ 1 2 +---------+ 1 | 0 1 | +---------+ 1 2 +-------------------+ 1 | string scalar | +-------------------+ 1 2 +---------+ 1 | 1 1 | +---------+
Then I add a row, and now is the orgtype a scalar instead, however it got 1 row and 1 column.
How can that be? What have I done wrong?
Comment