https://github.com/0xleif/dumb
A Dumb Protocol, Struct, and Class
https://github.com/0xleif/dumb
dumb mock
Last synced: about 2 months ago
JSON representation
A Dumb Protocol, Struct, and Class
- Host: GitHub
- URL: https://github.com/0xleif/dumb
- Owner: 0xLeif
- License: mit
- Created: 2020-08-21T02:58:30.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-21T22:48:15.000Z (over 4 years ago)
- Last Synced: 2025-02-10T23:41:47.347Z (3 months ago)
- Topics: dumb, mock
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dumb
> 🤷♂️
### Dumb Protocol
```swift
public protocol DumbProtocol {
var bool: Bool { get set }
var string: String { get set }
var int: Int { get set }
var double: Double { get set }
var float: Float { get set }
var array: [Any] { get set }
var set: Set { get set }
var dictionary: [AnyHashable: Any] { get set }
}
```### Dumb Struct
```swift
public struct DumbStruct: DumbProtocol {
public var bool: Bool
public var string: String
public var int: Int
public var double: Double
public var float: Float
public var array: [Any]
public var set: Set
public var dictionary: [AnyHashable : Any]
public init(bool: Bool = Bool.random(),
string: String = "Hello, World!",
int: Int = Int.random(in: 0 ... 100),
double: Double = Double.random(in: 0 ... 100),
float: Float = Float.random(in: 0 ... 100),
array: [Any] = (0 ... 100).map { _ in Int.random(in: 0 ... 100) },
set: Set = Set((0 ... 100).map { _ in Int.random(in: 0 ... 100) }),
dictionary: [AnyHashable : Any] = ["some": "value", 3.14: "other", "value": 3.14]) {
self.bool = bool
self.string = string
self.int = int
self.double = double
self.float = float
self.array = array
self.set = set
self.dictionary = dictionary
}
}
```### Dumb Class
```swift
public class DumbClass: DumbProtocol {
public var bool: Bool
public var string: String
public var int: Int
public var double: Double
public var float: Float
public var array: [Any]
public var set: Set
public var dictionary: [AnyHashable : Any]
public init(bool: Bool = Bool.random(),
string: String = "Hello, World!",
int: Int = Int.random(in: 0 ... 100),
double: Double = Double.random(in: 0 ... 100),
float: Float = Float.random(in: 0 ... 100),
array: [Any] = (0 ... 100).map { _ in Int.random(in: 0 ... 100) },
set: Set = Set((0 ... 100).map { _ in Int.random(in: 0 ... 100) }),
dictionary: [AnyHashable : Any] = ["some": "value", 3.14: "other", "value": 3.14]) {
self.bool = bool
self.string = string
self.int = int
self.double = double
self.float = float
self.array = array
self.set = set
self.dictionary = dictionary
}
}
```