<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>编程语言 on YuYoung&#39;s Blog</title>
    <link>https://yuyoung32.github.io/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/</link>
    <description>Recent content in 编程语言 on YuYoung&#39;s Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh</language>
    <lastBuildDate>Mon, 04 Oct 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://yuyoung32.github.io/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>函数闭包-Go&amp;Java</title>
      <link>https://yuyoung32.github.io/post/%E5%87%BD%E6%95%B0%E9%97%AD%E5%8C%85/</link>
      <pubDate>Mon, 04 Oct 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yuyoung32.github.io/post/%E5%87%BD%E6%95%B0%E9%97%AD%E5%8C%85/</guid>
      <description>函数闭包概念 闭包是由函数及其相关的引用环境组合而成的实体(即：闭包=函数+引用环境)。 在本质上，闭包是将函数内部和函数外部连接起来的桥梁，通过它可以修改函数的内部的变量。
闭包实现 在Go里，使用匿名函数实现。可见内部匿名函数被推出到外部后，就可以改变内部值。
package main import &amp;#34;fmt&amp;#34; // 实现斐波那契数列 func fibonacci() func() int { a:=0 b:=1 return func() int { temp:=b b=a+b a=temp return a } } func main() { f := fibonacci() for i := 0; i &amp;lt; 10; i++ { fmt.Println(f()) } } // 输出1 1 2 3 5 ... ////非闭包实现 //import &amp;#34;fmt&amp;#34; // //func main() { //	a:=1 //	b:=1 //	for i := 0; i &amp;lt; 10 ;i++{ //	fmt.</description>
    </item>
    
  </channel>
</rss>
