<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">See the code:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="color:rgb(187,44,162)">do</span><span style=""> {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(112,61,170)"><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(187,44,162)">var</span><span style="color:rgb(0,0,0)"> dictionary = </span><span style="">Dictionary</span><span style="color:rgb(0,0,0)"><</span><span style="">String</span><span style="color:rgb(0,0,0)">, </span><span style="">AnyObject</span><span style="color:rgb(0,0,0)">>()</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><span style=""> </span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> </span><span style="color:rgb(187,44,162)">func</span><span style=""> update<T:</span><span style="color:rgb(112,61,170)">AnyObject</span><span style="">>(value:</span><span style="color:rgb(79,129,135)">T</span><span style="">, key:</span><span style="color:rgb(112,61,170)">String</span><span style="">) {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> dictionary.</span><span style="color:rgb(61,29,129)">updateValue</span><span style="">(value, forKey: key)</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> }</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><span style=""> </span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> </span><span style="color:rgb(187,44,162)">let</span><span style=""> aBool = </span><span style="color:rgb(187,44,162)">true</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> </span><span style="color:rgb(187,44,162)">let</span><span style=""> key = </span><span style="color:rgb(209,47,27)">"testBool"</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><span style=""> </span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> </span><span style="color:rgb(49,89,93)">update</span><span style="">(aBool, key: key)</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"> </span><span style="">// cannot invoke 'update' with an argument list of type '(Bool, key: String)'</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;min-height:13px"><span style=""> </span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""> dictionary.</span><span style="color:rgb(61,29,129)">updateValue</span><span style="">(aBool, forKey: key)</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"> </span><span style="">// works</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style="">}</span></p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal"><span style=""><br></span></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">My own function will get the error as shown in the comment part. But it seams that Dictionary<String, AnyObject> has no issue. How to improving my code?</font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif"><br></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif">Zhaoxin</font></p></div></div>