What exactly does the word "Scalar" mean in this context?

In Lecture: Documents: Scalar Value Types, he keeps referring to Strings as “Scalar” types. But how does that make any sense? A scalar should be able to scale something. I can multiply a number by 5, but I can’t multiply a number by “apple”.

This CSSE answer suggests that strings are not scalar: https://cs.stackexchange.com/questions/47237/are-strings-scalar

Am I right in thinking that the correct term here is a “Primitive” data type?

@Aaron_Franke_59358 I think its one of those overloaded / interchangeable terms tbh despite the various definitions. I’ve always considered primitives to be thing like int, char, float, etc… and to an extent String. But in some definitions I’ve seen Scalar used to describe something that is a single value regardless of the data type…

1 Like

strings are not primitives in most languages either (but they are in JS, there is no char type) …

Whether they are scalar according to your operational definition depends on the language: perl & Python can multiply strings by a number.

I do follow the distinction between scalar (1 value) and collections/records/objects (multiple values).

1 Like

You have a misconception of what scalar means. It is not related to something that scales or can be multiplied. There’s a really good answer on stack overflow about Scalar vs Primitive that I think is worth checking out if you find scalar value types confusing.


String are not scalars. And this chapter should be use “primitive” instead of “scalar” which, by the way, is a term not used on MongoBD documention