In Ruby 2.7, an explicit Hash (with curly braces) as the last argument is implicitly converted to kwargs.
In Ruby 3.0+, an explicit Hash (with curly braces) as the last argument is treated as a Hash literal, and can't be parsed as kwargs.
In Ruby 2.7, an explicit Hash (with curly braces) as the last argument is implicitly converted to kwargs.
In Ruby 3.0+, an explicit Hash (with curly braces) as the last argument is treated as a Hash literal, and can't be parsed as kwargs.
import Foundation | |
import UIKit | |
class ConstraintTransaction { | |
private var constraints: [Constraint] = [] | |
func add(_ constraint: Constraint) { | |
constraints.append(constraint) | |
} | |
import UIKit | |
class ConstraintDSL { | |
private let view: UIView | |
private var chain: [NSLayoutConstraint] = [] | |
init(_ view: UIView) { | |
self.view = view | |
} | |
// Define Provider Protocols | |
protocol NetworkProvider { | |
var networkingService: NetworkServiceProtocol | |
} | |
protocol LoggingProvider { | |
var loggerService: LoggerServiceProtocol | |
} | |
protocol ConfigurationProvider { |
const Promise = require('bluebird'); | |
const fs = require('fs'); | |
const LineByLine = require('n-readlines'); | |
const { promisify } = require('util'); | |
const exec = promisify(require('child_process').exec); | |
const filesWithoutExtension = [ | |
'Podfile', | |
'Mintfile', | |
].reduce((acc, f) => { acc[f.toLowerCase()] = true; return acc; }, {}); // Convert to Set with lowercased filenames. |
extension JSONValue { | |
public var value: JSONPrimitive? { | |
switch self { | |
case .object(let value): return value | |
case .array(let value): return value | |
case .string(let value): return value | |
case .number(let value): return value | |
case .boolean(let value): return value | |
case .null: return nil |
extension JSONValue: Decodable { | |
public init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
if let value = try? container.decode(Bool.self) { | |
self = .boolean(value) | |
} else if let value = try? container.decode(Double.self) { | |
// Double covers Int as well | |
self = .number(value) | |
} else if let value = try? container.decode(String.self) { |
public enum JSONValue { | |
case object([String: JSONValue]) | |
case array([JSONValue]) | |
case string(String) | |
case number(Double) | |
case boolean(Bool) | |
case null | |
} |
public enum JSONValue { | |
case object([String: JSONValue]) | |
case array([JSONValue]) | |
case string(String) | |
case number(Double) | |
case boolean(Bool) | |
case null | |
public var value: JSONPrimitive? { |
import XCTest | |
fileprivate extension JSONValue { | |
var objectValue: [String: JSONValue]? { | |
switch self { | |
case .object(let value): return value | |
default: return nil | |
} | |
} | |
var arrayValue: [JSONValue]? { |