In addition to arrays, Julia supports associative arrays, sets and many other data structures. In this section we will introduce a few.
Associative arrays consist of collections of (key, values) pairs. In Julia associative arrays are called dictionaries (Dicts).
Let us look at a simple datatype to hold a user's credentials: ID, password, e-mail, and so on. We will not include a username as this will be the key to a credential datatype. In practice this would not be a great idea, as users often forget their usernames as well as their passwords!
To implement this we use a simple module. This includes a type and some functions which operate on that type. Note the inclusion of the export
statement which makes the type UserCreds
and the functions visible.
moduleAuth typeUserCreds uid::Int password::ASCIIString fullname::ASCIIString email::ASCIIString admin::Bool end function matchPwds(_mc::Dict{ASCIIString,UserCreds}, _name::ASCIIString, _pwd...