{"id":21300,"date":"2017-04-13T16:48:24","date_gmt":"2017-04-13T07:48:24","guid":{"rendered":"http:\/\/www.sejuku.net\/blog\/?p=21300"},"modified":"2024-05-06T11:41:36","modified_gmt":"2024-05-06T02:41:36","slug":"%e9%81%95%e3%81%84%e3%82%92%e7%9f%a5%e3%82%8b%ef%bc%81ruby%e3%81%aeproc%e3%81%a8lambda%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6%e3%81%ae5%e3%81%ae%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.sejuku.net\/blog\/21300","title":{"rendered":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01Web\u30b3\u30fc\u30c0\u30fc\u30fb\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u8c9d\u539f\uff08<a href=\"https:\/\/twitter.com\/touhicomu\" target=\"_blank\" rel=\"noopener\">@touhicomu<\/a>\uff09\u3067\u3059\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u3001<span style=\"color: #339966\"><strong>Ruby<\/strong><\/span>\u306b\u3088\u308b<span style=\"color: #339966\"><strong>Proc\u3001lambda<\/strong><\/span>\u306e\u4f7f\u3044\u65b9\u3068\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f<span style=\"color: #339966\"><strong>Proc\u3001lambda<\/strong><\/span>\u306e\u3001<\/p>\n<ul>\n<li><span style=\"color: #ff0000\"><strong>Proc\u3068lambda\u306e\u4f7f\u3044\u65b9<\/strong><\/span><\/li>\n<li><span style=\"color: #ff0000\"><strong>Proc\u3068lambda\u3078\u306e\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/strong><\/span><\/li>\n<li><span style=\"color: #ff0000\"><strong>Proc\u3092\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u306b\u6e21\u3059\u65b9\u6cd5<\/strong><\/span><\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u57fa\u672c\u7684\u306a\u5185\u5bb9\u304b\u3089\u3001<\/p>\n<ul>\n<li><span style=\"color: #ff0000\"><strong>\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50<\/strong><\/span><\/li>\n<li><span style=\"color: #ff0000\"><strong>\u30af\u30ed\u30fc\u30b8\u30e3\u30fc<\/strong><\/span><\/li>\n<\/ul>\n<p>\u306a\u3069\u306e\u5fdc\u7528\u7684\u306a\u4f7f\u3044\u65b9\u306b\u95a2\u3057\u3066\u3082\u5b66\u7fd2\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30da\u30fc\u30b8\u3067\u3001<span style=\"color: #339966\"><strong>Ruby<\/strong><\/span>\u306e<span style=\"color: #339966\"><strong>Proc\u3001lambda<\/strong><\/span>\u306e\u4f7f\u3044\u65b9\u3092\u3088\u304f\u628a\u63e1\u3057\u3066\u81ea\u5206\u306e\u30b9\u30ad\u30eb\u3068\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h2>Proc\u3068lambda\u306e\u4f7f\u3044\u65b9\u3068\u4f7f\u3044\u5206\u3051<\/h2>\n<h3>Proc\u3068lambda\u306e\u4f7f\u3044\u65b9<\/h3>\n<p><span style=\"color: #ff0000;background-color: #ffff99\"><strong>Proc\u306f\u3001def\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u3057\u305f\u3082\u306e\u3067\u3001Proc.new\u30e1\u30bd\u30c3\u30c9\u306b\u3088\u3063\u3066def\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u3092\u751f\u6210<\/strong><\/span>\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">p1 = Proc.new do |val|\r\n  p &quot;arg=&quot; + val.to_s\r\nend\r\n \r\np1.call(1)    #=&gt;&quot;arg=1&quot;\r\n \r\np2 = p1\r\np2.call(100) #=&gt;&quot;arg=100&quot;<\/pre>\n<p>\u4ee5\u4e0a\u306e\u3088\u3046\u306b\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570p1\u306bProc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4ee3\u5165\u3057\u3001<span style=\"color: #339966\"><strong>call<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u306b\u3088\u308a\u3001Proc.new\u6642\u306b\u5b9a\u7fa9\u3057\u305f<span style=\"color: #0000ff\"><strong>Proc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>Proc<\/strong><\/span>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f<span style=\"color: #0000ff\"><strong>def\u3068\u307b\u307c\u540c\u3058<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001p1\u3092p2\u306b\u4ee3\u5165\u3057\u3066p2\u304b\u3089\u5168\u304f\u540c\u3058Proc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5bfe\u3057\u3066<span style=\"color: #339966\"><strong>lambda<\/strong><\/span>\u306f\u3069\u3046\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u5b9f\u306f\u3001lambda\u306fProc.new\u3068<span style=\"color: #0000ff\"><strong>\u307b\u307c\u540c\u3058<\/strong><\/span>\u52d5\u4f5c\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>\u9055\u3044\u306f\u3001\u6b21\u7bc0\u3067\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">l1 = lambda do |val|\r\n  p &quot;arg=&quot; + val.to_s\r\nend\r\n \r\nl1.call(1)    #=&gt;&quot;arg=1&quot;\r\n \r\nl2 = l1\r\nl2.call(100) #=&gt;&quot;arg=100&quot;<\/pre>\n<h3>Proc\u3068lambda\u306e\u9055\u3044<\/h3>\n<h4>lambda\u306f\u5f15\u6570\u306e\u6570\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3044\u308b<\/h4>\n<p><span style=\"color: #339966\"><strong>lambda<\/strong><\/span>\u306f\u5f15\u6570\u306e\u6570\u3092<span style=\"color: #0000ff\"><strong>\u6587\u6cd5\u30c1\u30a7\u30c3\u30af<\/strong><\/span>\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u547c\u3073\u51fa\u3059\u6642\u306b\u5f15\u6570\u306e\u6570\u304c\u9055\u3046\u3068\u3001<span style=\"color: #ff0000\"><strong>\u30a8\u30e9\u30fc<\/strong><\/span>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>Proc<\/strong><\/span>\u306fdef\u3068\u540c\u3058\u3067\u3001\u5f15\u6570\u306b\u5024\u306e\u6307\u5b9a\u304c\u306a\u304b\u3063\u305f\u5834\u5408\u306f<span style=\"color: #0000ff\"><strong>nil<\/strong><\/span>\u304c\u5f15\u6570\u306b\u4ee3\u5165\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">p1 = Proc.new do |val1, val2|\r\n  p &quot;arg=&quot; + val1.to_s + &quot; , &quot; + val2.to_s\r\nend\r\n \r\nl1 = lambda do |val1, val2|\r\n  p &quot;arg=&quot; + val1.to_s + &quot; , &quot; + val2.to_s\r\nend\r\n \r\np1.call(1)    #=&gt; \r\nl1.call(1)    #=&gt; wrong number of arguments (given 1, expected 2) (ArgumentError)<\/pre>\n<p>lambda\u306f\u3001\u5f15\u6570\u306e\u6570\u304c\u9055\u3046\u3068\u3001<span style=\"color: #ff0000\"><strong>(ArgumentError)<\/strong><\/span>\u3092\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<h4>return\u3059\u308b\u3068\u304d\u306e\u6319\u52d5\u304c\u9055\u3046<\/h4>\n<p>Proc\u3068lambda\u306f<span style=\"color: #0000ff\"><strong>return\u6587<\/strong><\/span>\u306e\u6319\u52d5\u304c\u9055\u3044\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>Proc\u306ereturn<\/strong><\/span>\u306f\u3001call\u306e<span style=\"color: #0000ff\"><strong>\u547c\u3073\u51fa\u3057\u5143<\/strong><\/span>\u3067return\u3092\u5b9f\u884c\u3057\u305f\u3053\u3068\u3068\u898b\u306a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>lambda\u306ereturn<\/strong><\/span>\u306f\u3001call\u306e<span style=\"color: #0000ff\"><strong>\u547c\u3073\u51fa\u3057\u5148<\/strong><\/span>\u3001\u3064\u307e\u308a<span style=\"color: #339966\"><strong>lambda\u81ea\u8eab\u306ereturn<\/strong><\/span>\u3067\u3042\u308b\u3082\u306e\u3068\u898b\u306a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">def proc_def\r\n  p1 = Proc.new { return p &quot;proc's return&quot;}\r\n  p1.call\r\n  p &quot;proc_def's end&quot;\r\nend\r\n \r\ndef lambda_def\r\n  l1 = lambda{ return p &quot;lambda's return&quot;}\r\n  l1.call\r\n  p &quot;lambda_def's end&quot;\r\nend\r\n \r\nproc_def\r\n#\u5b9f\u884c\u7d50\u679c\r\n#=&gt;&quot;proc's return&quot;\r\n \r\nlambda_def\r\n#\u5b9f\u884c\u7d50\u679c\r\n#=&gt;&quot;lambda's return&quot;\r\n#=&gt;&quot;lambda_def's end&quot;<\/pre>\n<p>proc_def\u3067\u306f\u3001Proc\u3067return\u3057\u305f\u6642\u70b9\u3067\u3001proc_def\u304c\u7d42\u4e86\u3057\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<p>\u5bfe\u3057\u3066\u3001lambda_def\u3067\u306f\u3001lambda\u304creturn\u3057\u3066\u3082\u3001lambda_def\u306f\u51e6\u7406\u3092\u7d99\u7d9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>Proc\u3068lambda\u3078\u306e\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/h2>\n<h3>\u6e21\u3059\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>Proc\u3068lambda\u3078\u306e<span style=\"color: #339966\"><strong>\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/strong><\/span>\u306b\u306f\u3044\u304f\u3064\u304b\u7a2e\u985e\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u305e\u308cProc\u3068lambda\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30e1\u30bd\u30c3\u30c9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001Proc\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">p1 = Proc.new do |val|\r\n  p &quot;arg=&quot; + val.to_s\r\nend\r\n \r\np1.call(1)    #=&gt;&quot;arg=1&quot;\r\np1[&quot;value&quot;]   #=&gt;&quot;arg=value&quot;\r\np1.([1,2,3])  #=&gt;&quot;arg=[1, 2, 3]&quot;<\/pre>\n<p>\u6b21\u306blambda\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">l1 = lambda do |val|\r\n  p &quot;arg=&quot; + val.to_s\r\nend\r\n \r\nl1.call(1)    #=&gt;&quot;arg=1&quot;\r\nl1[&quot;value&quot;]   #=&gt;&quot;arg=value&quot;\r\nl1.([1,2,3])  #=&gt;&quot;arg=[1, 2, 3]&quot;<\/pre>\n<p>\u305d\u308c\u305e\u308c\u3001<span style=\"color: #339966\"><strong>call()\u3001[]\u3001.()<\/strong><\/span>\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30e1\u30bd\u30c3\u30c9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u57fa\u672c\u7684\u306a\u6e21\u3057\u65b9<\/h3>\n<p>Proc\u3078\u306e\u57fa\u672c\u7684\u306a\u5f15\u6570\u306e\u6e21\u3057\u65b9\u3068\u3057\u3066\u3001<\/p>\n<ul>\n<li>\u914d\u5217\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/li>\n<li>\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/li>\n<li>\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/li>\n<\/ul>\n<p>\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>\u914d\u5217\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/h4>\n<p>\u307e\u305a\u306f\u3001\u914d\u5217\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/p>\n<p>proc\u306e<span style=\"color: #339966\"><strong>call()<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u306b\u3001\u8907\u6570\u306e\u5f15\u6570\u3092\u4e0e\u3048\u305f\u5834\u5408\u3001\u53d7\u3051\u53d6\u308bproc\u306e\u5074\u3067\u306f\u3001\u305d\u308c\u3089\u306e<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u3092\u914d\u5217\u3068\u3057\u3066<\/strong><\/span>\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002<\/p>\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308bproc\u5074\u306e\u5f15\u6570\u540d\u306b\u306f\u300c<span style=\"color: #339966\"><strong>*\uff08\u30a2\u30b9\u30bf\u30ea\u30b9\u30af\uff09<\/strong><\/span>\u300d\u3092\u660e\u793a\u7684\u306b\u3064\u3051\u3066\u304a\u304b\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u70b9\u3067\u3059\u3002<\/p>\n<p>\u300c*\u300d\u3092\u3064\u3051\u3066\u3044\u306a\u3044\u5f15\u6570\u540d\u3001\u305f\u3068\u3048\u3070\u300carg\u300d\u306e\u5834\u5408\u3001call()\u30e1\u30bd\u30c3\u30c9\u306e<span style=\"color: #ff0000\"><strong>\u7b2c1\u5f15\u6570\u306e\u307f<\/strong><\/span>\u300carg\u300d\u306b\u5165\u308a\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u306f\u3001\u914d\u5217\u300c<span style=\"color: #339966\"><strong>args<\/strong><\/span>\u300d\u306b\u300c<span style=\"color: #339966\"><strong>each<\/strong><\/span>\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30eb\u30fc\u30d7\u3057\u3001\u9806\u306b<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u306e\u9806\u756a\u3068\u5024<\/strong><\/span>\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \"># \u5f15\u6570\u3092\u914d\u5217\u3068\u3057\u3066\u53d7\u3051\u53d6\u308b\r\ndump = Proc.new do |*args|\r\n\r\n  idx = 1\r\n  \r\n  # \u914d\u5217\u3092\u30eb\u30fc\u30d7\r\n  args.each do |item|\r\n    \r\n    # \u53d7\u3051\u53d6\u3063\u305f\u5f15\u6570\u30921\u500b1\u500b\u51fa\u529b\r\n    p &quot;No.#{idx} arg = #{item}&quot;\r\n    \r\n    idx+=1\r\n  end\r\nend\r\n\r\ndump.call(10,9,8,&quot;c&quot;,&quot;b&quot;,&quot;a&quot;)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">&quot;No.1 arg = 10&quot;\r\n&quot;No.2 arg = 9&quot;\r\n&quot;No.3 arg = 8&quot;\r\n&quot;No.4 arg = c&quot;\r\n&quot;No.5 arg = b&quot;\r\n&quot;No.6 arg = a&quot;<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u304c\u3001\u300cdump.call()\u300d\u306b\u6e21\u3057\u305f\u5f15\u6570\u306e\u9806\u756a\u3068\u5024\u306b\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<p>Proc\u306e<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u5b9a\u7fa9\u90e8<\/strong><\/span>\uff08\u300c|\u300d\u304b\u3089\u300c|\u300d\u5185\uff09\u306b\u300c<span style=\"color: #339966\"><strong>*args<\/strong><\/span>\u300d\u3068\u3057\u3066\u3044\u3066\u3082\u3001<span style=\"color: #0000ff\"><strong>Proc\u5185\u90e8<\/strong><\/span>\u3067\u306f\u300c<span style=\"color: #339966\"><strong>args<\/strong><\/span>\u300d\u3060\u3051\u3067\u914d\u5217\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/h4>\n<p><span style=\"color: #339966\"><strong>\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570<\/strong><\/span>\u3068\u306f\u3001Proc\u306e<span style=\"color: #0000ff\"><strong>\u547c\u3073\u51fa\u3057\u5143\u306e\u5f15\u6570\u304c\u7701\u7565<\/strong><\/span>\u3055\u308c\u3066Proc\u304c\u547c\u3073\u51fa\u3055\u308c\u305f\u969b\u306b<span style=\"color: #0000ff\"><strong>\u4f7f\u7528\u3055\u308c\u308b<\/strong><\/span>\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u6c7a\u3081\u3066\u3042\u308b\uff09<span style=\"color: #0000ff\"><strong>\u5024<\/strong><\/span>\u304c\u3042\u308b\u5f15\u6570\u3067\u3059\u3002<\/p>\n<p>\u547c\u3073\u51fa\u3057\u5143\u3067\u660e\u793a\u7684\u306b\u5024\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f\u4f7f\u7528\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f\u3001\u4ee5\u4e0b\u306e\u7591\u4f3c\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">Proc.new do  | \u5f15\u6570\u540d1 = \u30c7\u30d5\u30a9\u30eb\u30c8\u50241, \u5f15\u6570\u540d2 = \u30c7\u30d5\u30a9\u30eb\u30c8\u50242, \u30fb\u30fb\u30fb|\r\n  \u30b3\u30fc\u30c9\u90e81\r\n  \u30b3\u30fc\u30c9\u90e82\r\n  \u30b3\u30fc\u30c9\u90e83\r\n \u30fb\u30fb\u30fb\r\nend<\/pre>\n<p>\u5b9f\u969b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:ruby decode:true \"># \u9762\u7a4d\u3068\u4f53\u7a4d\u3092\u8a08\u7b97\u3059\u308bProc\r\n# y\u3001 z\u306b\u3064\u3044\u3066\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308b\u306e\u3067\u7701\u7565\u53ef\u80fd\u3002\r\nkeisan = Proc.new do |x, y = 5, z = 1|\r\n  # \u53d7\u3051\u53d6\u3063\u305f\u5f15\u6570\u3092\u8868\u793a\r\n  p &quot;x = #{x}, y = #{y}, z = #{z}&quot;\r\n\r\n  # \u9577\u65b9\u5f62\u306e\u9762\u7a4d\u3092\u8868\u793a\r\n  p &quot;menseki = &quot; + (x * y).to_s unless x == nil\r\n  \r\n  # \u7acb\u65b9\u4f53\u306e\u4f53\u7a4d\u3092\u8868\u793a\r\n  p &quot;taiseki = &quot; + (x * y * z).to_s unless x == nil\r\nend\r\n\r\np &quot;keisan No.1 ---------------&quot;\r\nkeisan.call(1)\r\n\r\np &quot;keisan No.2 ---------------&quot;\r\nkeisan.call(2, 10)\r\n\r\np &quot;keisan No.3 ---------------&quot;\r\nkeisan.call(2, 20, 10)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">&quot;keisan No.1 ---------------&quot;\r\n&quot;x = 1, y = 5, z = 1&quot;\r\n&quot;menseki = 5&quot;\r\n&quot;taiseki = 5&quot;\r\n&quot;keisan No.2 ---------------&quot;\r\n&quot;x = 2, y = 10, z = 1&quot;\r\n&quot;menseki = 20&quot;\r\n&quot;taiseki = 20&quot;\r\n&quot;keisan No.3 ---------------&quot;\r\n&quot;x = 2, y = 20, z = 10&quot;\r\n&quot;menseki = 40&quot;\r\n&quot;taiseki = 400&quot;<\/pre>\n<p>\u5f15\u6570y\u3084\u3001z\u3001\u3092\u7701\u7565\u3057\u305f\u5834\u5408\u3001\u3067<span style=\"color: #0000ff\"><strong>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<\/strong><\/span>\u304c\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u306f\u5f15\u6570\u8a18\u8ff0\u90e8\u306e<span style=\"color: #0000ff\"><strong>\u53f3\u6a4b\u304b\u3089\u9806<\/strong><\/span>\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h4>\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u306e\u6e21\u3057\u65b9<\/h4>\n<p>\u5f15\u6570\u3092<span style=\"color: #339966\"><strong>\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570<\/strong><\/span>\u3068\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u306b\u306f\u4ee5\u4e0b\u306e\u7279\u5fb4\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u6307\u5b9a\u3059\u308b\u9806\u756a\u306b\u4f9d\u5b58\u3057\u306a\u3044<\/li>\n<li>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u6307\u5b9a\u3067\u304d\u308b<\/li>\n<li>\u30cf\u30c3\u30b7\u30e5\u3092\u6307\u5b9a\u3067\u304d\u308b<\/li>\n<li>\u30cf\u30c3\u30b7\u30e5\u3092\u6e21\u3059\u306e\u3068\u4e8b\u5b9f\u4e0a\u540c\u3058<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u3001\u5b9f\u969b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:ruby decode:true \"># \u5f15\u6570\u3092\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u3068\u3057\u3066\u53d7\u3051\u53d6\u308b\r\nhello = Proc.new do |who: &quot;you&quot;, whom: &quot;jobs&quot;, what: &quot;hello&quot;|\r\n  p who.to_s + &quot; said &quot; + whom.to_s + &quot; that &quot; + what.to_s\r\nend\r\n\r\nhello.call()\r\nhello.(whom:&quot;Bill&quot;)\r\nhello.(what:&quot;Billed to you&quot;, to:&quot;Tim&quot;) #=&gt;  unknown keyword: to (ArgumentError)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">&quot;you said jobs that hello&quot;\r\n&quot;you said Bill that hello&quot;\r\ndef_keyword_args.rb:2:in `block in &lt;main&gt;': unknown keyword: to (ArgumentError)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306e1\u884c\u76ee\u30682\u884c\u76ee\u306f\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u306e<span style=\"color: #0000ff\"><strong>\u7701\u7565<\/strong><\/span>\u304c\u3046\u307e\u304f\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>2\u884c\u76ee\u306f\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u304c<span style=\"color: #0000ff\"><strong>\u9806\u756a\u306b\u4f9d\u5b58\u3057\u306a\u3044<\/strong><\/span>\u3053\u3068\u3092\u793a\u3059\u4f8b\u3067\u3059\u3002<\/p>\n<p>3\u884c\u76ee\u306f\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u30ef\u30fc\u30c9\u540d\u3092\u4e0e\u3048\u308b\u3068<span style=\"color: #ff0000\"><strong>unknown keyword\u30a8\u30e9\u30fc<\/strong><\/span>\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u4f8b\u3067\u3059\u3002<\/p>\n<p>\u306a\u304aRuby\u306eProc\u306e\u5f15\u6570\u306b\u95a2\u3057\u3066\u8a73\u3057\u304f\u306f\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3092\u53c2\u7167\u3055\u308c\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/19669\" class=\"blog-card-anchor\">\n                <div class=\"blog-card\">\n                <div class=\"blog-card-content\">\n                    <div class=\"blog-card-thumbnail\">\n                    <img decoding=\"async\" class=\"blog-card-thumbnail-img\" src=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/image-92-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">\u3010Ruby\u5165\u9580\u3011\u5f15\u6570\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081\u3010\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3 \u30aa\u30d7\u30b7\u30e7\u30f3\u3011<\/div>\n                    <div class=\"blog-card-update-date\">\u66f4\u65b0\u65e5\uff1a2024\u5e745\u67086\u65e5<\/div>\n                    <\/div>\n                <\/div>\n                <\/div>\n            <\/a>\n            \n<h3>\u5fdc\u7528\u7684\u306a\u6e21\u3057\u65b9<\/h3>\n<h4>\u5f15\u6570\u306e\u6570\u3092\u793a\u3059arity<\/h4>\n<p>Proc\u306e<span style=\"color: #339966\"><strong>arity<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u306f\u5f15\u6570\u306e\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u306a\u304a\u3001\u3053\u3053\u3067\u306f\u3001Proc.new\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u306a\u304f\u3001<span style=\"color: #339966\"><strong>proc\u30ad\u30fc\u30ef\u30fc\u30c9<\/strong><\/span>\u3067Proc.new\u3068\u7b49\u4fa1\u306a\u3053\u3068\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001<span style=\"color: #339966\"><strong>proc\u30ad\u30fc\u30ef\u30fc\u30c9<\/strong><\/span>\u306e\u66f8\u304d\u65b9\u306f<span style=\"color: #339966\"><strong>lambda\u30ad\u30fc\u30ef\u30fc\u30c9<\/strong><\/span>\u306e\u66f8\u304d\u65b9\u3068<span style=\"color: #0000ff\"><strong>\u540c\u3058<\/strong><\/span>\u3067\u3042\u308b\u3053\u3068\u3092\u628a\u63e1\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">proc1 = proc do |x| x end\r\nproc2 = proc do |x,y| [x,y] end\r\nproc3 = proc do |*ary| ary end\r\nproc4 = proc do |x, *ary| [x,ary] end\r\nproc5 = proc do |key1:0,key2:0| key1 == key2 end\r\n\r\np proc1.arity\r\np proc2.arity\r\np proc3.arity\r\np proc4.arity\r\np proc5.arity<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">1\r\n2\r\n-1\r\n-2\r\n0<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306e\u3088\u3046\u306b1\u884c\u76ee\u30682\u884c\u76ee\u306f\u3001<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u306e\u6570<\/strong><\/span>\u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>3\u884c\u76ee\u306f\u3001\u5f15\u6570\u3092\u300c<span style=\"color: #339966\"><strong>\u914d\u5217\u5f15\u6570<\/strong><\/span>\u300d\u3068\u5b9a\u7fa9\u3057\u305f\u305f\u3081\u3001\u300c<span style=\"color: #0000ff\"><strong>-1<\/strong><\/span>\u300d\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>4\u884c\u76ee\u306f\u3001\u300c\u7b2c1\u5f15\u6570\u306f<span style=\"color: #339966\"><strong>\u901a\u5e38\u306e\u5f15\u6570<\/strong><\/span>\u3001\u305d\u308c\u4ee5\u964d\u306f<span style=\"color: #339966\"><strong>\u914d\u5217\u5f15\u6570<\/strong><\/span>\u300d\u3068\u5b9a\u7fa9\u3057\u305f\u305f\u3081\u3001\u300c<span style=\"color: #0000ff\"><strong>-2<\/strong><\/span>\u300d\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>5\u884c\u76ee\u306f\u3001\u5f15\u6570\u3092\u300c<span style=\"color: #339966\"><strong>\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570<\/strong><\/span>\u300d\u3068\u5b9a\u7fa9\u3057\u305f\u305f\u3081\u3001\u300c<span style=\"color: #0000ff\"><strong>0<\/strong><\/span>\u300d\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u30e1\u30bd\u30c3\u30c9\u304c\u53ef\u5909\u9577\u5f15\u6570\u3092\u53d7\u3051\u4ed8\u3051\u308b\u5834\u5408\u3001\u8ca0\u306e\u6574\u6570\u300c<span style=\"color: #0000ff\"><strong>-(\u5fc5\u8981\u3068\u3055\u308c\u308b\u5f15\u6570\u306e\u6570 + 1)<\/strong><\/span>\u300d\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h4>\u5f15\u6570\u60c5\u5831\u3092\u793a\u3059parameters<\/h4>\n<p>Proc\u306e<span style=\"color: #339966\"><strong>parameters<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u306f\u3001<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u60c5\u5831<\/strong><\/span>\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u5f15\u6570\u60c5\u5831\u306f\u4ee5\u4e0b\u306e\u7279\u5fb4\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>1\u5f15\u6570\u3042\u305f\u308a1\u500b\u306e\u914d\u5217\u3067\u8868\u3055\u308c\u3066\u3044\u308b<\/li>\n<li>\u5168\u4f53\u306e\u5f15\u6570\u306f\u914d\u5217\u3067\u3001\u8907\u6570\u306e\u5b50\u914d\u5217\u3092\u3082\u3064\u89aa\u914d\u5217<\/li>\n<li>\u5f15\u6570\u306e\u30bf\u30a4\u30d7\u3092\u793a\u3059\u60c5\u5831\u306f\u898f\u5b9a\u306e\u30b7\u30f3\u30dc\u30eb\u306b\u306a\u3063\u3066\u3044\u308b<\/li>\n<li>\u5f15\u6570\u540d\u306f\u30b7\u30f3\u30dc\u30eb\u3067\u8868\u3055\u308c\u308b<\/li>\n<\/ul>\n<pre class=\"lang:ruby decode:true \">proc1 = proc do |x| x end\r\nproc2 = proc do |x,y| [x,y] end\r\nproc3 = proc do |*ary| ary end\r\nproc4 = proc do |x, *ary| [x,ary] end\r\nproc5 = proc do |key1:0,key2:0| key1 == key2 end\r\n\r\np proc1.parameters\r\np proc2.parameters\r\np proc3.parameters\r\np proc4.parameters\r\np proc5.parameters<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">[[:opt, :x]]\r\n[[:opt, :x], [:opt, :y]]\r\n[[:rest, :ary]]\r\n[[:opt, :x], [:rest, :ary]]\r\n[[:key, :key1], [:key, :key2]]<\/pre>\n<p>\u5f15\u6570\u30bf\u30a4\u30d7\u3092\u8868\u3059\u30b7\u30f3\u30dc\u30eb\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306eURL\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/docs.ruby-lang.org\/ja\/latest\/method\/Method\/i\/parameters.html\" target=\"_blank\" rel=\"noopener\">instance method Method#parameters (Ruby 2.4.0)<\/a><\/p>\n<h2>Proc\u3092\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u306b\u6e21\u3059\u65b9\u6cd5<\/h2>\n<h3>\u57fa\u672c\u7684\u306a\u6e21\u3057\u65b9<\/h3>\n<p>Proc\u306f\u3001\u300c<span style=\"color: #339966\"><strong>&amp;<\/strong><\/span>\u300d\u3092\u3064\u3051\u308c\u3070\u3001<span style=\"color: #339966\"><strong>\u30d6\u30ed\u30c3\u30af<\/strong><\/span>\u3068\u3057\u3066<span style=\"color: #339966\"><strong>each<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u306a\u3069\u306b\u6e21\u305b\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u3067\u306f\u3001\u914d\u5217\u306e<span style=\"color: #339966\"><strong>each<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u306b\u5bfe\u3057\u3001<span style=\"color: #339966\"><strong>proc1<\/strong><\/span>\u306b\u300c<span style=\"color: #339966\"><strong>&amp;<\/strong><\/span>\u300d\u3092\u3064\u3051\u3066\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \"># proc\r\nproc1 = Proc.new do |x| \r\n  p x * 2 \r\nend\r\n\r\n# i\u30921\u304b\u30895\u307e\u3067\u6570\u3048\u4e0a\u3052\u308b\r\n[1,2,3,4,5].each(&amp;proc1)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">2\r\n4\r\n6\r\n8\r\n10<\/pre>\n<p>each\u3067\u306f1\u304b\u30895\u307e\u3067<span style=\"color: #0000ff\"><strong>\u6570\u3048\u4e0a\u3052<\/strong><\/span>\u3001\u305d\u308c\u305e\u308c\u306e\u30eb\u30fc\u30d7\u4e2d\u3067proc1\u306b<span style=\"color: #0000ff\"><strong>\u5f15\u6570<\/strong><\/span>\uff081\u304b\u30895\u307e\u3067\u306e\u30eb\u30fc\u30d7\u5909\u6570\u5024\uff09\u3068<span style=\"color: #0000ff\"><strong>\u51e6\u7406\u306e\u5236\u5fa1<\/strong><\/span>\u3092\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>proc1\u3067\u306f\u5f15\u6570\u306e<span style=\"color: #0000ff\"><strong>2\u500d\u306e\u6570\u5024<\/strong><\/span>\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u5fdc\u7528\u7684\u306a\u6e21\u3057\u65b9<\/h3>\n<p><span style=\"color: #339966\"><strong>\u901a\u5e38\u306e\u30e1\u30bd\u30c3\u30c9<\/strong><\/span>\u306b\u3082Proc\u306b\u300c<span style=\"color: #339966\"><strong>&amp;<\/strong><\/span>\u300d\u3092\u3064\u3051\u3066<span style=\"color: #339966\"><strong>\u30d6\u30ed\u30c3\u30af<\/strong><\/span>\u3068\u3057\u3066\u6e21\u305b\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u306f\u300c<span style=\"color: #339966\"><strong>yield n1, n2, \u2026 <\/strong><\/span>\u300d\u30e1\u30bd\u30c3\u30c9\u3067\u5f15\u6570n1\u3001n2\u3001\u30fb\u30fb\u30fb\u3068<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u3092\u4e0e\u3048<\/strong><\/span>\u306a\u304c\u3089\u3001<span style=\"color: #0000ff\"><strong>\u5236\u5fa1\u3092\u30d6\u30ed\u30c3\u30af\u306b<\/strong><\/span>\u79fb\u305b\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u306fProc\u3092<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u3092\uff11\u3064\u53d7\u3051\u53d6\u308b\u30d6\u30ed\u30c3\u30af<\/strong><\/span>\u3068\u3057\u3066\u6e21\u3059\u65b9\u6cd5\u3092\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \"># \u5f15\u6570\u30921\u3064\u3082\u3064Proc\u306e\u4f8b\r\nproc1 = proc do |i| \r\n  p i.to_s\r\nend\r\n\r\n# \u30d6\u30ed\u30c3\u30af\u3092\u53d7\u3051\u53d6\u308b\u95a2\u6570\r\ndef test\r\n  yield &quot;hello&quot;\r\nend\r\n\r\n# test\u95a2\u6570\u306bProc\u306b&amp;\u3092\u3064\u3051\u3066\u30d6\u30ed\u30c3\u30af\u3068\u3057\u3066\u6e21\u3059\r\ntest &amp;proc1<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">&quot;hello&quot;<\/pre>\n<p>\u30e1\u30bd\u30c3\u30c9test\u306e\u300c<span style=\"color: #339966\"><strong>yield \u201chello\u201d<\/strong><\/span>\u300d\u306b\u3066\u30d6\u30ed\u30c3\u30af\u300c<span style=\"color: #339966\"><strong>&amp;proc1<\/strong><\/span>\u300d\u306b\u5bfe\u3057<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u300c\u201dhello\u201d\u300d<\/strong><\/span>\u3092\u6e21\u3057\u5236\u5fa1\u3092\u30d6\u30ed\u30c3\u30af\u306b\u4ee5\u964d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u300cproc1\u300d\u304c\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u5f15\u6570\u300c\u201dhello\u201d\u300d\u3092<span style=\"color: #0000ff\"><strong>p\u30e1\u30bd\u30c3\u30c9\u3067\u51fa<\/strong><\/span>\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306bProc\u3092<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u30922\u3064\u53d7\u3051\u53d6\u308b\u30d6\u30ed\u30c3\u30af<\/strong><\/span>\u3068\u3057\u3066\u6e21\u3059\u65b9\u6cd5\u3092\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:ruby decode:true \"># \u5f15\u6570\u30922\u3064\u3082\u3064Proc\u306e\u4f8b\r\nproc1 = proc do |i,j| \r\n  p (i+j).to_s\r\nend\r\n\r\n# \u30d6\u30ed\u30c3\u30af\u3092\u53d7\u3051\u53d6\u308b\u95a2\u6570\r\ndef test\r\n  yield 5, 10\r\nend\r\n\r\n# test\u95a2\u6570\u306bProc\u306b&amp;\u3092\u3064\u3051\u3066\u30d6\u30ed\u30c3\u30af\u3068\u3057\u3066\u6e21\u3059\r\ntest &amp;proc1<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">&quot;15&quot;<\/pre>\n<p>\u30d6\u30ed\u30c3\u30af\u306e<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u304c2\u500b<\/strong><\/span>\u306e\u5834\u5408\u3067\u3082\u3001<span style=\"color: #0000ff\"><strong>\u300cyield\u300d\u306e\u5f15\u6570\u30922\u500b<\/strong><\/span>\u4e0e\u3048\u308c\u3070\u3001OK\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<h2>Proc\u3068lambda\u306e\u5fdc\u7528<\/h2>\n<h3>\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50<\/h3>\n<p>Ruby\u306b\u306flambda\u3068\u540c\u7b49\u306e\u6a5f\u80fd\u3092\u6301\u3064<span style=\"color: #339966\"><strong>\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50<\/strong><\/span>\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>lambda\u3068\u540c\u3058\u304f<\/p>\n<ul>\n<li>def\u306e\u5f15\u6570<\/li>\n<li>def\u306e\u30b3\u30fc\u30c9<\/li>\n<\/ul>\n<p>\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">a1 = -&gt; (val) { p &quot;arg=&quot; + val.to_s }\r\n \r\n \r\na1.call(1)    #=&gt;&quot;arg=1&quot;\r\na1[&quot;value&quot;]   #=&gt;&quot;arg=value&quot;\r\na1.([1,2,3])  #=&gt;&quot;arg=[1, 2, 3]&quot;\r\n \r\na2 = a1\r\na2.call(100) #=&gt;&quot;arg=100&quot;\r\n \r\na3= a1\r\na3.call(200,300) #=&gt;wrong number of arguments (given 2, expected 1) (ArgumentError)<\/pre>\n<p><span style=\"color: #339966\"><strong>-&gt;<\/strong><\/span>\u304c<span style=\"color: #0000ff\"><strong>\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50<\/strong><\/span>\u3067\u3001\u300c<span style=\"color: #339966\"><strong>lambda<\/strong><\/span>\u300d\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u540c\u7b49\u306e\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>(val)<\/strong><\/span>\u304c\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50\u3067\u306e<span style=\"color: #0000ff\"><strong>\u5f15\u6570<\/strong><\/span>\u3067\u3059\u3002lambda\u3067\u306f<span style=\"color: #339966\"><strong>|val|<\/strong><\/span>\u3067\u3057\u305f\u306d\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>{\u30fb\u30fb\u30fb}<\/strong><\/span>\u304c<span style=\"color: #0000ff\"><strong>\u30b3\u30fc\u30c9\u90e8<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>lambda\u3068\u540c\u3058\u304f\u3001\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50\u3067\u3082<span style=\"color: #0000ff\"><strong>\u5f15\u6570\u306e\u6570\u3092\u30c1\u30a7\u30c3\u30af<\/strong><\/span>\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30af\u30ed\u30fc\u30b8\u30e3\u30fc<\/h3>\n<p><span style=\"color: #339966\"><strong>\u30af\u30ed\u30fc\u30b8\u30e3\u30fc<\/strong><\/span>\u3068\u306f\u3001<span style=\"color: #339966\"><strong>Proc<\/strong><\/span>\u3084<span style=\"color: #339966\"><strong>lambda<\/strong><\/span>\u306e\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b<span style=\"color: #0000ff\"><strong>\u30b9\u30b3\u30fc\u30d7\u5185<\/strong><\/span>\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u5909\u6570\u3092\u3001<span style=\"color: #0000ff\"><strong>Proc\u3084lambda\u5185\u3067\u3082<\/strong><\/span>\u4f7f\u7528\u3067\u304d\u308b\u6a5f\u80fd\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001Proc\u30e1\u30bd\u30c3\u30c9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308bdef\u30e1\u30bd\u30c3\u30c9\u306e<span style=\"color: #0000ff\"><strong>\u30b9\u30b3\u30fc\u30d7\u5185\u306e\u5909\u6570<\/strong><\/span>\u306f\u3001\u5168\u3066<span style=\"color: #0000ff\"><strong>Proc\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u30a2\u30af\u30bb\u30b9<\/strong><\/span>\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">def hello(str)\r\n  closed_str = str\r\n  Proc.new do\r\n    &quot;hello, &quot; + closed_str.to_s\r\n  end\r\nend\r\n \r\nh1 = hello(&quot;Jon&quot;)\r\np h1.call #=&gt; &quot;hello, Jon&quot;\r\n \r\nc2 = hello(&quot;Kity&quot;)\r\np c2.call #=&gt; &quot;hello, Kity&quot;<\/pre>\n<p><span style=\"color: #339966\"><strong>lambda<\/strong><\/span>\u3067\u3082\u3001Proc\u3068<span style=\"color: #0000ff\"><strong>\u540c\u7b49\u306e\u30af\u30ed\u30fc\u30b8\u30e3\u30fc<\/strong><\/span>\u304c\u7d44\u3081\u307e\u3059\u3002<\/p>\n<pre class=\"lang:ruby decode:true \">def hello(str)\r\n  closed_str = str\r\n  lambda do\r\n    &quot;hello, &quot; + closed_str.to_s\r\n  end\r\nend\r\n \r\nh1 = hello(&quot;Jon&quot;)\r\np h1.call #=&gt; &quot;hello, Jon&quot;\r\n \r\nc2 = hello(&quot;Kity&quot;)\r\np c2.call #=&gt; &quot;hello, Kity&quot;<\/pre>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u4eca\u56de\u306f\u3001<span style=\"color: #339966\"><strong>Ruby<\/strong><\/span>\u306e<span style=\"color: #339966\"><strong>Proc\u3001lambda<\/strong><\/span>\u3092\u5b66\u7fd2\u3057\u307e\u3057\u305f\uff01<\/p>\n<p>\u5b66\u7fd2\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u632f\u308a\u8fd4\u3063\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<ul>\n<li><strong>Proc\u3068lambda\u306f\u307b\u307c\u540c\u3058\u6a5f\u80fd\u3092\u6301\u3061\u3001\u95a2\u6570\u3092\u6301\u3061\u6b69\u3051\u308b<\/strong><\/li>\n<li><strong>Proc\u306e\u5f15\u6570\u306e\u4ed5\u69d8\u306fdef\u306e\u5f15\u6570\u3068\u540c\u3058<\/strong><\/li>\n<li><strong>lambda\u306e\u5f15\u6570\u306e\u4ed5\u69d8\u306fdef\u306e\u5f15\u6570\u3068\u306f\u9055\u3044\u53b3\u3057\u304f\u30c1\u30a7\u30c3\u30af\u3055\u308c\u308b<\/strong><\/li>\n<li><strong>arity\u3067\u5f15\u6570\u306e\u6570\u3092\u3001parameters\u3067\u5f15\u6570\u306e\u60c5\u5831\u3092\u5f97\u3089\u308c\u308b<\/strong><\/li>\n<li><strong>Proc\u306b\u300c&amp;\u300d\u3092\u4ed8\u3051\u308b\u3068\u30e1\u30bd\u30c3\u30c9\u306b\u30d6\u30ed\u30c3\u30af\u3068\u3057\u3066\u6e21\u305b\u308b<\/strong><\/li>\n<li><strong>lamda\u306e\u7c21\u7565\u8868\u73fe\u3068\u3057\u3066\u300c\u30a2\u30ed\u30fc\u6f14\u7b97\u5b50\u300d\u304c\u3042\u308b<\/strong><\/li>\n<li><strong>Proc\u3001lambda\u3068\u540c\u3058\u30b9\u30b3\u30fc\u30d7\u306b\u3042\u308b\u5909\u6570\u306fProc\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\uff08\u30af\u30ed\u30fc\u30b8\u30e3\u30fc\uff09<\/strong><\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u306e\u5185\u5bb9\u3092\u518d\u78ba\u8a8d\u3057\u3001\u305c\u3072\u81ea\u5206\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u751f\u304b\u3057\u5b66\u7fd2\u3092\u9032\u3081\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01Web\u30b3\u30fc\u30c0\u30fc\u30fb\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u8c9d\u539f\uff08@touhicomu\uff09\u3067\u3059\u3002 \u4eca\u65e5\u306f\u3001Ruby\u306b\u3088\u308bProc\u3001lambda\u306e\u4f7f\u3044\u65b9\u3068\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u3053\u306e\u8a18\u4e8b\u3067\u306fProc\u3001lambda\u306e\u3001 Proc [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":31686,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"swell_btn_cv_data":"","footnotes":""},"categories":[2352],"tags":[815,814,114,68],"class_list":["post-21300","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-study","tag-lambda","tag-proc","tag-ruby","tag-68"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0<\/title>\n<meta name=\"description\" content=\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sejuku.net\/blog\/21300\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\" \/>\n<meta property=\"og:description\" content=\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sejuku.net\/blog\/21300\" \/>\n<meta property=\"og:site_name\" content=\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sejuku2013\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/sejuku2013\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-13T07:48:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-06T02:41:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/ruby_proc03.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/samuraijuku\" \/>\n<meta name=\"twitter:site\" content=\"@samuraijuku\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300\"},\"author\":{\"name\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/person\\\/e8ca7fd09857a736a25e6b4455a3ab61\"},\"headline\":\"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011\",\"datePublished\":\"2017-04-13T07:48:24+00:00\",\"dateModified\":\"2024-05-06T02:41:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300\"},\"wordCount\":211,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/ruby_proc03.jpg\",\"keywords\":[\"lambda\",\"proc\",\"ruby\",\"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\"],\"articleSection\":[\"Ruby\u5b66\u7fd2\"],\"inLanguage\":\"ja\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300\",\"name\":\"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/ruby_proc03.jpg\",\"datePublished\":\"2017-04-13T07:48:24+00:00\",\"dateModified\":\"2024-05-06T02:41:36+00:00\",\"description\":\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#primaryimage\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/ruby_proc03.jpg\",\"contentUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/ruby_proc03.jpg\",\"width\":700,\"height\":400,\"caption\":\"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/21300#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\",\"name\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\",\"description\":\"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u306e\u3059\u3079\u3066\u304c\u30b3\u30b3\u306b\u3002\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\",\"name\":\"\u682a\u5f0f\u4f1a\u793eSAMURAI\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/logo.png\",\"width\":600,\"height\":600,\"caption\":\"\u682a\u5f0f\u4f1a\u793eSAMURAI\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/sejuku2013\",\"https:\\\/\\\/x.com\\\/samuraijuku\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCCFOQO5aDK0xXam4cUQXT8g\\\/featured\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/person\\\/e8ca7fd09857a736a25e6b4455a3ab61\",\"name\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g\",\"caption\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\"},\"description\":\"\u3010\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3011 DX\u8a8d\u5b9a\u53d6\u5f97\u4e8b\u696d\u8005\u306b\u9078\u5b9a\u3055\u308c\u3066\u3044\u308b\u682a\u5f0f\u4f1a\u793eSAMURAI\u306e\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u30fb\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u90e8\u304c\u904b\u55b6\u3002\u300c\u8cea\u306e\u9ad8\u3044IT\u6559\u80b2\u3092\u3001\u3059\u3079\u3066\u306e\u4eba\u306b\u300d\u3092\u30df\u30c3\u30b7\u30e7\u30f3\u306b\u3001IT\u30fb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b66\u3073\u59cb\u3081\u305f\u521d\u5b66\u8005\u306e\u65b9\u306b\u5411\u3051\u8a18\u4e8b\u3092\u57f7\u7b46\u3002 \u7d2f\u8a08\u6307\u5c0e\u8005\u65704\u4e075,000\u540d\u4ee5\u4e0a\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u300c\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u300d\u3001\u7d2f\u8a08\u767b\u9332\u8005\u65701\u4e078,000\u4eba\u4ee5\u4e0a\u306e\u30aa\u30f3\u30e9\u30a4\u30f3\u5b66\u7fd2\u30b5\u30fc\u30d3\u30b9\u300c\u4f8d\u30c6\u30e9\u30b3\u30e4\u300d\u3067\u6271\u3046\u6559\u6750\u958b\u767a\u306e\u30ce\u30a6\u30cf\u30a6\u30012013\u5e74\u306e\u5275\u696d\u304b\u3089\u904b\u55b6\u3067\u5f97\u305f\u77e5\u898b\u306b\u57fa\u3065\u304d\u3001\u8a18\u4e8b\u306e\u57f7\u7b46\u3060\u3051\u3067\u306a\u304f\u7de8\u96c6\u30fb\u76e3\u4fee\u3082\u62c5\u5f53\u3057\u3066\u3044\u307e\u3059\u3002 \u3010\u5c02\u9580\u5206\u91ce\u3011 IT\\\/Web\u958b\u767a\\\/AI\u30fb\u30ed\u30dc\u30c3\u30c8\u958b\u767a\\\/\u30a4\u30f3\u30d5\u30e9\u958b\u767a\\\/\u30b2\u30fc\u30e0\u958b\u767a\\\/AI\\\/Web\u30c7\u30b6\u30a4\u30f3\",\"sameAs\":[\"https:\\\/\\\/www.sejuku.net\\\/\",\"https:\\\/\\\/www.facebook.com\\\/sejuku2013\\\/\",\"https:\\\/\\\/www.instagram.com\\\/samuraiengineer_official\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/samuraijuku\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCCFOQO5aDK0xXam4cUQXT8g\"],\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/author\\\/samurai-blog\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sejuku.net\/blog\/21300","og_locale":"ja_JP","og_type":"article","og_title":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","og_description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002","og_url":"https:\/\/www.sejuku.net\/blog\/21300","og_site_name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","article_publisher":"https:\/\/www.facebook.com\/sejuku2013","article_author":"https:\/\/www.facebook.com\/sejuku2013\/","article_published_time":"2017-04-13T07:48:24+00:00","article_modified_time":"2024-05-06T02:41:36+00:00","og_image":[{"width":700,"height":400,"url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/ruby_proc03.jpg","type":"image\/jpeg"}],"author":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/samuraijuku","twitter_site":"@samuraijuku","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sejuku.net\/blog\/21300#article","isPartOf":{"@id":"https:\/\/www.sejuku.net\/blog\/21300"},"author":{"name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/person\/e8ca7fd09857a736a25e6b4455a3ab61"},"headline":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011","datePublished":"2017-04-13T07:48:24+00:00","dateModified":"2024-05-06T02:41:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sejuku.net\/blog\/21300"},"wordCount":211,"publisher":{"@id":"https:\/\/www.sejuku.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/21300#primaryimage"},"thumbnailUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/ruby_proc03.jpg","keywords":["lambda","proc","ruby","\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0"],"articleSection":["Ruby\u5b66\u7fd2"],"inLanguage":"ja"},{"@type":"WebPage","@id":"https:\/\/www.sejuku.net\/blog\/21300","url":"https:\/\/www.sejuku.net\/blog\/21300","name":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","isPartOf":{"@id":"https:\/\/www.sejuku.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sejuku.net\/blog\/21300#primaryimage"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/21300#primaryimage"},"thumbnailUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/ruby_proc03.jpg","datePublished":"2017-04-13T07:48:24+00:00","dateModified":"2024-05-06T02:41:36+00:00","description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002","breadcrumb":{"@id":"https:\/\/www.sejuku.net\/blog\/21300#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sejuku.net\/blog\/21300"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.sejuku.net\/blog\/21300#primaryimage","url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/ruby_proc03.jpg","contentUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/09\/ruby_proc03.jpg","width":700,"height":400,"caption":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sejuku.net\/blog\/21300#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sejuku.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011"}]},{"@type":"WebSite","@id":"https:\/\/www.sejuku.net\/blog\/#website","url":"https:\/\/www.sejuku.net\/blog\/","name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","description":"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u306e\u3059\u3079\u3066\u304c\u30b3\u30b3\u306b\u3002","publisher":{"@id":"https:\/\/www.sejuku.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sejuku.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":"Organization","@id":"https:\/\/www.sejuku.net\/blog\/#organization","name":"\u682a\u5f0f\u4f1a\u793eSAMURAI","url":"https:\/\/www.sejuku.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2023\/07\/logo.png","contentUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2023\/07\/logo.png","width":600,"height":600,"caption":"\u682a\u5f0f\u4f1a\u793eSAMURAI"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/sejuku2013","https:\/\/x.com\/samuraijuku","https:\/\/www.youtube.com\/channel\/UCCFOQO5aDK0xXam4cUQXT8g\/featured"]},{"@type":"Person","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/person\/e8ca7fd09857a736a25e6b4455a3ab61","name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/secure.gravatar.com\/avatar\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g","caption":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8"},"description":"\u3010\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3011 DX\u8a8d\u5b9a\u53d6\u5f97\u4e8b\u696d\u8005\u306b\u9078\u5b9a\u3055\u308c\u3066\u3044\u308b\u682a\u5f0f\u4f1a\u793eSAMURAI\u306e\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u30fb\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u90e8\u304c\u904b\u55b6\u3002\u300c\u8cea\u306e\u9ad8\u3044IT\u6559\u80b2\u3092\u3001\u3059\u3079\u3066\u306e\u4eba\u306b\u300d\u3092\u30df\u30c3\u30b7\u30e7\u30f3\u306b\u3001IT\u30fb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b66\u3073\u59cb\u3081\u305f\u521d\u5b66\u8005\u306e\u65b9\u306b\u5411\u3051\u8a18\u4e8b\u3092\u57f7\u7b46\u3002 \u7d2f\u8a08\u6307\u5c0e\u8005\u65704\u4e075,000\u540d\u4ee5\u4e0a\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u300c\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u300d\u3001\u7d2f\u8a08\u767b\u9332\u8005\u65701\u4e078,000\u4eba\u4ee5\u4e0a\u306e\u30aa\u30f3\u30e9\u30a4\u30f3\u5b66\u7fd2\u30b5\u30fc\u30d3\u30b9\u300c\u4f8d\u30c6\u30e9\u30b3\u30e4\u300d\u3067\u6271\u3046\u6559\u6750\u958b\u767a\u306e\u30ce\u30a6\u30cf\u30a6\u30012013\u5e74\u306e\u5275\u696d\u304b\u3089\u904b\u55b6\u3067\u5f97\u305f\u77e5\u898b\u306b\u57fa\u3065\u304d\u3001\u8a18\u4e8b\u306e\u57f7\u7b46\u3060\u3051\u3067\u306a\u304f\u7de8\u96c6\u30fb\u76e3\u4fee\u3082\u62c5\u5f53\u3057\u3066\u3044\u307e\u3059\u3002 \u3010\u5c02\u9580\u5206\u91ce\u3011 IT\/Web\u958b\u767a\/AI\u30fb\u30ed\u30dc\u30c3\u30c8\u958b\u767a\/\u30a4\u30f3\u30d5\u30e9\u958b\u767a\/\u30b2\u30fc\u30e0\u958b\u767a\/AI\/Web\u30c7\u30b6\u30a4\u30f3","sameAs":["https:\/\/www.sejuku.net\/","https:\/\/www.facebook.com\/sejuku2013\/","https:\/\/www.instagram.com\/samuraiengineer_official\/","https:\/\/x.com\/https:\/\/twitter.com\/samuraijuku","https:\/\/www.youtube.com\/channel\/UCCFOQO5aDK0xXam4cUQXT8g"],"url":"https:\/\/www.sejuku.net\/blog\/author\/samurai-blog"}]}},"_links":{"self":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts\/21300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/comments?post=21300"}],"version-history":[{"count":0,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts\/21300\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/media\/31686"}],"wp:attachment":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/media?parent=21300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/categories?post=21300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/tags?post=21300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}