Concatenate elements without separators

assert [1,2,3].plain_to_s == "123"
assert [11..13].plain_to_s  == "111213"
assert (new Array[Int]).plain_to_s == ""

Property definitions

core :: abstract_text $ Collection :: plain_to_s
	# Concatenate elements without separators
	#
	# ~~~
	# assert [1,2,3].plain_to_s == "123"
	# assert [11..13].plain_to_s  == "111213"
	# assert (new Array[Int]).plain_to_s == "" # empty collection
	# ~~~
	fun plain_to_s: String
	do
		var s = new Buffer
		for e in self do if e != null then s.append(e.to_s)
		return s.to_s
	end
lib/core/text/abstract_text.nit:2356,2--2368,4

core :: flat $ Array :: plain_to_s
	# Fast implementation
	redef fun plain_to_s
	do
		var l = _length
		if l == 0 then return ""
		var its = _items.as(not null)
		var first = its[0]
		if l == 1 then if first == null then return "" else return first.to_s
		var na = new NativeArray[String](l)
		var i = 0
		var sl = 0
		var mypos = 0
		while i < l do
			var itsi = its[i]
			if itsi == null then
				i += 1
				continue
			end
			var tmp = itsi.to_s
			sl += tmp.byte_length
			na[mypos] = tmp
			i += 1
			mypos += 1
		end
		var ns = new CString(sl + 1)
		ns[sl] = 0
		i = 0
		var off = 0
		while i < mypos do
			var tmp = na[i]
			if tmp isa FlatString then
				var tpl = tmp._byte_length
				tmp._items.copy_to(ns, tpl, tmp._first_byte, off)
				off += tpl
			else
				for j in tmp.substrings do
					var s = j.as(FlatString)
					var slen = s._byte_length
					s._items.copy_to(ns, slen, s._first_byte, off)
					off += slen
				end
			end
			i += 1
		end
		return new FlatString.with_infos(ns, sl, 0)
	end
lib/core/text/flat.nit:1485,2--1530,4