Skip to content

Commit

Permalink
GDictionary convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldeicaza committed Sep 24, 2023
1 parent 4edb7b0 commit 4f230ab
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Sources/SwiftGodot/Extensions/GDictionary.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// File.swift
//
//
// Created by Miguel de Icaza on 9/23/23.
//

import Foundation

public extension GDictionary {
/// Convenience subscript that uses a String as the key to access the
/// elements in the dictionary. Merely wraps this on a Variant.
public subscript (key: String) -> Variant? {
get {
return self [Variant (key)]
}
set {
self [Variant (key)] = newValue
}
}

/// Convenience subscript that uses a StringName as the key to access the
/// elements in the dictionary. Merely wraps this on a Variant.
public subscript (key: StringName) -> Variant? {
get {
return self [Variant (key)]
}
set {
self [Variant (key)] = newValue
}
}
}

0 comments on commit 4f230ab

Please sign in to comment.