def create_dict(objectx, *args):
return {arg: objectx for arg in args}
# Example usage:
class ObjectX:
pass
obj = ObjectX()
result = create_dict(obj, "key1", "key2", "key3")
print(result)
// Java
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
ObjectX obj = new ObjectX();
Map<String, ObjectX> result = createDict(obj, "key1", "key2", "key3");
System.out.println(result);
}
public static Map<String, ObjectX> createDict(ObjectX objectx, String... args) {
Map<String, ObjectX> map = new HashMap<>();
for (String arg : args) {
map.put(arg, objectx);
}
return map;
}
}
class ObjectX {
// Your ObjectX implementation
}
// Kotlin
fun createDict(objectx: ObjectX, vararg args: String): Map<String, ObjectX> {
return args.associateWith { objectx }
}
// Example usage:
class ObjectX
fun main() {
val obj = ObjectX()
val result = createDict(obj, "key1", "key2", "key3")
println(result)
}
' VB.NET
Imports System.Collections.Generic
Module Module1
Sub Main()
Dim obj As New ObjectX()
Dim result As Dictionary(Of String, ObjectX) = CreateDict(obj, "key1", "key2", "key3")
For Each kvp As KeyValuePair(Of String, ObjectX) In result
Console.WriteLine($"{kvp.Key}: {kvp.Value}")
Next
End Sub
Function CreateDict(ByVal objectx As ObjectX, ByVal ParamArray args() As String) As Dictionary(Of String, ObjectX)
Dim dict As New Dictionary(Of String, ObjectX)()
For Each arg As String In args
dict(arg) = objectx
Next
Return dict
End Function
End Module
Class ObjectX
' Your ObjectX implementation
End Class
// C#
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
ObjectX obj = new ObjectX();
Dictionary<string, ObjectX> result = CreateDict(obj, "key1", "key2", "key3");
foreach (var kvp in result)
{
Console.WriteLine($"{kvp.Key}: {kvp.Value}");
}
}
static Dictionary<string, ObjectX> CreateDict(ObjectX objectx, params string[] args)
{
var dict = new Dictionary<string, ObjectX>();
foreach (var arg in args)
{
dict[arg] = objectx;
}
return dict;
}
}
class ObjectX
{
// Your ObjectX implementation
}
// Swift
func createDict(objectx: ObjectX, args: String...) -> [String: ObjectX] {
var dict = [String: ObjectX]()
for arg in args {
dict[arg] = objectx
}
return dict
}
// Example usage:
class ObjectX {
// Your ObjectX implementation
}
let obj = ObjectX()
let result = createDict(objectx: obj, args: "key1", "key2", "key3")
print(result)