Skip to content

Commit f22fc41

Browse files
authored
Update Crystal.jl
1 parent 862f0b3 commit f22fc41

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Crystal.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ AtomsBase.keys(sys::Crystal) = (:lattice, :basis, :N_unit_cells, :atoms)
7575
Base.getindex(sys::Crystal, x::Symbol) = hasfield(Crystal, x) ? getfield(sys, x) : error("No field `$x` in Atom object. Allowed keys are $(keys(sys)).")
7676
AtomsBase.haskey(sys::Crystal, x::Symbol) = hasfield(Crystal, x)
7777
Base.pairs(sys::Crystal) = (k => sys[k] for k in keys(sys))
78-
78+
Base.get(sys::Crystal, x::Symbol, default) = hasfield(Crystal, x) ? getfield(sys,x) : default
7979

8080
Base.length(sys::Crystal) = length(sys.atoms)
8181
Base.iterate(sys::Crystal, state = 1) = state > length(sys) ? nothing : (sys.atoms[state], state + 1)
@@ -118,4 +118,4 @@ end
118118

119119
function Base.show(io::IO, ::MIME"text/plain", sys::Crystal)
120120
print(io, "Crystal with ", length(sys)," atoms.")
121-
end
121+
end

0 commit comments

Comments
 (0)