I presume because objects don't print as nicely as records. As reason will try to print the methods alongside the values.
Js.log2("Does this work", myNewCat);
"Does this work" [[4,15,null,-278822339,null,243512077,null,461513217,null,588852681],16,"Cool Cat",5,"Dave",5]
One way would be to add a show method to all your objects, where you manually make a string.
class immutableCat(name, age) = {
as _;
val name = name;
val age = age;
pub show = "Cat {name: " ++ name ++ ", age: " ++ string_of_int(age) ++ "}";
};
let myImmutableCat: immutableCat = new immutableCat("Cool Cat", 5);
let show = obj => obj#show; // put this in a Utility module somewhere
Js.log2("Does this work", show(myImmutableCat));
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Awesome series! Really. Thanks.
I can't seem to log
myImmutableCat
ormyNewCat
. Is there a trick to that?Thank again.
I presume because objects don't print as nicely as records. As reason will try to print the methods alongside the values.
One way would be to add a
show
method to all your objects, where you manually make a string.