digitalmars.D.learn - string version of array
- Tony (2/2) Nov 13 2017 Is there an easy way to get the string representation of an
- rikki cattermole (14/16) Nov 13 2017 struct Foo {
- Andrea Fontana (6/23) Nov 14 2017 Why not
- rikki cattermole (3/31) Nov 14 2017 .text is essentially short hand, that's all. I use it as it is more
- Tony (4/21) Nov 14 2017 Thanks. That flipped function calling syntax definitely takes
- Dr. Assembly (3/28) Nov 14 2017 if you consider this as a property, it makes alot of sense the
- Timoses (3/10) Nov 14 2017 To give it a name I suppose it's this:
Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?
Nov 13 2017
On 14/11/2017 7:54 AM, Tony wrote:Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)]
Nov 13 2017
On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote:On 14/11/2017 7:54 AM, Tony wrote:Why not import std.conv : to; writeln(data.to!string); ?Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)]
Nov 14 2017
On 14/11/2017 8:16 AM, Andrea Fontana wrote:On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote:.text is essentially short hand, that's all. I use it as it is more descriptive as to my intention.On 14/11/2017 7:54 AM, Tony wrote:Why not import std.conv : to; writeln(data.to!string); ?Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)]
Nov 14 2017
On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote:On 14/11/2017 7:54 AM, Tony wrote:Thanks. That flipped function calling syntax definitely takes some getting used to.Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)]
Nov 14 2017
On Tuesday, 14 November 2017 at 08:21:59 UTC, Tony wrote:On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote:if you consider this as a property, it makes alot of sense the var.propName syntax.On 14/11/2017 7:54 AM, Tony wrote:Thanks. That flipped function calling syntax definitely takes some getting used to.Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string?struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)]
Nov 14 2017
On Tuesday, 14 November 2017 at 14:00:54 UTC, Dr. Assembly wrote:On Tuesday, 14 November 2017 at 08:21:59 UTC, Tony wrote:To give it a name I suppose it's this: UFCS: https://dlang.org/spec/function.html#pseudo-memberOn Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote: Thanks. That flipped function calling syntax definitely takes some getting used to.if you consider this as a property, it makes alot of sense the var.propName syntax.
Nov 14 2017