Equivalent Julia code for a Python class with counter variables

This is one possibility:

mutable struct Student
    gpa::Int
    record::Dict{Any, Any}
    name::String
end

let counter = 0
    global function Student()
        counter += 1
        return Student(0, Dict(), "Student $counter")
    end
end
1 Like