On Saturday, 31 August 2024 at 22:06:26 UTC, kdevel wrote:
Is that functionally different from
```
void main()
{
import std.stdio;
int[string] test = ["hello": 42];
if (auto p = "hello" in test)
{
writeln("hello => ", *p);
}
}
```
It's essentially the same. I only
On 01/09/2024 4:34 AM, Lance Bachmeier wrote:
On Saturday, 31 August 2024 at 15:38:49 UTC, ryuukk_ wrote:
Let's see how other languages do it:
```zig
map.put("hello", 42);
// get pointer
if (map.get("hello")) |*it| {
std.log.debug("{}", .{it});
}
// get value
On Saturday, 31 August 2024 at 14:25:29 UTC, Paul Backus wrote:
[...]
Once the next release of Phobos comes out, with [PR 9039][1]
merged, you'll be able to do it like this:
```d
import std.typecons;
Nullable!V maybeGet(K, V)(V[K] aa, K key)
{
if (auto ptr = key in aa)
return null
On Saturday, 31 August 2024 at 16:34:00 UTC, Lance Bachmeier
wrote:
On Saturday, 31 August 2024 at 15:38:49 UTC, ryuukk_ wrote:
Let's see how other languages do it:
```zig
map.put("hello", 42);
// get pointer
if (map.get("hello")) |*it| {
std.log.debug("{}", .{it});
}
On Saturday, 31 August 2024 at 15:38:49 UTC, ryuukk_ wrote:
Let's see how other languages do it:
```zig
map.put("hello", 42);
// get pointer
if (map.get("hello")) |*it| {
std.log.debug("{}", .{it});
}
// get value
if (map.get("hello")) |it| {
std.log.deb
Let's see how other languages do it:
```zig
map.put("hello", 42);
// get pointer
if (map.get("hello")) |*it| {
std.log.debug("{}", .{it});
}
// get value
if (map.get("hello")) |it| {
std.log.debug("{}", .{it});
}
```
No imports, no templates, ONE LIN
On Saturday, 31 August 2024 at 14:25:29 UTC, Paul Backus wrote:
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote:
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
{
}
}
```
Is there a way to get the value instead of a point
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote:
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
{
}
}
```
Is there a way to get the value instead of a pointer? while
keeping the conciseness (one line)
Once the next rel
On Saturday, 31 August 2024 at 13:00:42 UTC, Steven Schveighoffer
wrote:
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote:
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
{
}
}
```
Is there a way to get the value instead o
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote:
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
{
}
}
```
Is there a way to get the value instead of a pointer? while
keeping the conciseness (one line)
Maybe if(auto it
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
{
}
}
```
Is there a way to get the value instead of a pointer? while
keeping the conciseness (one line)
11 matches
Mail list logo