The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
DB::Serializable
only handles creating objects from query results & not creating table schema or formatting query strings to insert data?
JSON::Serializable
except if it for some reason only gave you from_json
but not to_json
?
x
, @x
, or self.x
to refer to an instance variable in an instance method? I seem to be able to use all 3 with the same effect.
@x
is the only "safe" thing that will always resolve to an ivar, even if there is another local var or method named x...so is there no reason to use the other 2, other than to make things less explicit and confusing? :)
self.x
is if you have customer logic in the getter and/or are using a lazily initialized ivar
var x = [1, 2, 3, 4, 5]
var y = [6, 7, 8, 9, 10]
x[1..2] = y[1..2] # x => [1, 7, 8, 4, 5]