小编dns*_*mkl的帖子

D中的整数到字符串转换

如何在D中将整数转换为字符串?就像是

int i = 15
string message = "Value of 'i' is " ~ toString(i); // cast(string) i - also does not work 
Run Code Online (Sandbox Code Playgroud)

谷歌给我带来了关于如何使用探戈的答案,但我想要的是phobos版本.

casting d phobos

14
推荐指数
2
解决办法
4106
查看次数

std.algorithm.joiner(string [],string) - 为什么结果元素是dchar而不是char?

我尝试编译以下代码:

import std.algorithm;
void main()
{
    string[] x = ["ab", "cd", "ef"]; // 'string' is same as 'immutable(char)[]'
    string space = " ";
    char z = joiner( x, space ).front(); // error
}
Run Code Online (Sandbox Code Playgroud)

dmd带有错误的结尾编译:

 test.d(8): Error: cannot implicitly convert expression (joiner(x,space).front()) of type dchar to char
Run Code Online (Sandbox Code Playgroud)

更改char zdchar z确定错误消息,但我很感兴趣,为什么它出现在第一位.

为什么结果joiner(string[],string).front()是dchar而不是char?

(文档http://dlang.org/phobos/std_algorithm.html#joiner中没有任何内容)

d phobos dmd

7
推荐指数
1
解决办法
389
查看次数

std.algorithm.map的结果

有人会说什么std.algorithm.map回报?(链接到一些文档页面将非常感激)从错误消息其结果是类型Result

ulong[] x = [1,2,3];
ulong[] y = std.algorithm.map!"a"(x); // Error: cannot implicitly convert <..> of type Result to ulong[]
Run Code Online (Sandbox Code Playgroud)

http://dlang.org/phobos/std_algorithm.html#map中,关于它的信息非常少:

The call map!(fun)(range) returns a range of which elements are obtained by applying fun(x) left to right for all x in range
Run Code Online (Sandbox Code Playgroud)

由此我不清楚,我能做什么或不能做什么.

types d map

6
推荐指数
1
解决办法
477
查看次数

D编程语言中的空字符串

D编程语言中的空字符串是什么?

字符串是字符数组(http://dlang.org/arrays.html#strings)
可能:alias immutable(char)[] string

基于那个空字符串应该是一个空数组.但那么,空数组是什么样的东西?

有任何想法吗?

arrays string d

4
推荐指数
2
解决办法
655
查看次数

标签 统计

d ×4

phobos ×2

arrays ×1

casting ×1

dmd ×1

map ×1

string ×1

types ×1