<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Встроенные методы объекта.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13656&amp;type=atom" />
	<updated>2018-04-27T17:23:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13656</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Встроенные методы объекта.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124961#p124961" />
			<content type="html"><![CDATA[<p>Бобра вам!<br />b := a.Clone().InsertAt(2, 7)<br />Это присвоение интересно тем, что метод .InsertAt никогда ничего не возвращает (что описано в справке).<br />Метод является операцией над массивом, но не создает новый.<br />Стало быть переменная b всегда пуста.<br />Предлагаю расписать это на две строки.<br /></p><div class="quotebox"><cite>KusochekDobra пишет:</cite><blockquote><p>первый раз и выходит</p></blockquote></div><p>И все будет входить и выходить, замечательно выходить!</p>]]></content>
			<author>
				<name><![CDATA[KusochekBobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34401</uri>
			</author>
			<updated>2018-04-27T17:23:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124961#p124961</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Встроенные методы объекта.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124960#p124960" />
			<content type="html"><![CDATA[<p>Всем добра!</p><p>Так, работает:<br /></p><div class="codebox"><pre><code>
a := [13, 45, 67, 89]
b := a.Clone()
b.InsertAt(2, 7)

aFunc(a*)
aFunc(b*)
OutputDebug,Finish
aFunc(one, two, three, four, five := 0) {
	OutputDebug,Call
	MsgBox,,Title,% one &quot;`n&quot;  two &quot;`n&quot; three &quot;`n&quot; four &quot;`n&quot; five
}
</code></pre></div><p>И так:<br /></p><div class="codebox"><pre><code>
a := [13, 45, 67, 89]
b := InsertMe(CloneMe(a), 7, 2)

aFunc(a*)
aFunc(b*)
aFunc(a.Clone()*)
aFunc(InsertMe(CloneMe(a), 9, 3)*)
aFunc(InsertMe(a.Clone(), 19, 4)*)

OutputDebug,Finish
aFunc(one, two, three, four, five := 0) {
	OutputDebug,Call
	MsgBox,,Title,% one &quot;`n&quot;  two &quot;`n&quot; three &quot;`n&quot; four &quot;`n&quot; five
}
CloneMe(a) {
	b := []
	Loop,% a.Length()
		b.Push(a[A_Index])
	return b
}
InsertMe(b, item, pos := 1) {
	c := [], i := 1
	Loop,% b.Length() + 1
		c.Push(A_Index != pos ? b[i++] : item)
	return c
}
</code></pre></div><p>А так, вызывает только первый раз и выходит:<br /></p><div class="codebox"><pre><code>
a := [13, 45, 67, 89]
b := a.Clone().InsertAt(2, 7)

aFunc(a*)
aFunc(b*)
aFunc(a.Clone().InsertAt(2, 7)*)
aFunc((a.Clone()).InsertAt(2, 7)*)

c := a.Clone()
aFunc(c.InsertAt(2, 7)*)

OutputDebug,Finish
aFunc(one, two, three, four, five := 0) {
	OutputDebug,Call
	MsgBox,,Title,% one &quot;`n&quot;  two &quot;`n&quot; three &quot;`n&quot; four &quot;`n&quot; five
}
</code></pre></div><p>Скажите пожалуйста, это следует отправить в баг-репорт, или я не правильно делаю запись?</p><p><strong>UPD:</strong><br />Туплю. InsertAt() - ведь ничего не возвращает, а только модифицирует объект.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2018-04-27T17:00:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124960#p124960</id>
		</entry>
</feed>
