summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-print/mrblib/print.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-04-30 23:47:47 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-05-01 00:00:14 +0900
commit8f362eaf8a49af23c2c68d7d84b24c5211578881 (patch)
tree35ec754e7b9cadb1889c315352aaf351b75ffe4c /mrbgems/mruby-print/mrblib/print.rb
parent519dc3d19c355e53f3fa539da1696b6f4c40d87d (diff)
downloadmruby-8f362eaf8a49af23c2c68d7d84b24c5211578881.tar.gz
mruby-8f362eaf8a49af23c2c68d7d84b24c5211578881.zip
io.rb,print.rb: `puts` to expand array arguments.
As CRuby behaves.
Diffstat (limited to 'mrbgems/mruby-print/mrblib/print.rb')
-rw-r--r--mrbgems/mruby-print/mrblib/print.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/mrbgems/mruby-print/mrblib/print.rb b/mrbgems/mruby-print/mrblib/print.rb
index 6383901ee..96ee71fe9 100644
--- a/mrbgems/mruby-print/mrblib/print.rb
+++ b/mrbgems/mruby-print/mrblib/print.rb
@@ -19,6 +19,37 @@ module Kernel
args.__svalue
end
+ # 15.3.1.2.10
+ # 15.3.1.3.35
+ def print(*args)
+ i = 0
+ len = args.size
+ while i < len
+ __printstr__ args[i].to_s
+ i += 1
+ end
+ end
+
+ # 15.3.1.2.11
+ # 15.3.1.3.39
+ def puts(*args)
+ i = 0
+ len = args.size
+ while i < len
+ s = args[i]
+ if s.kind_of?(Array)
+ puts(*s)
+ else
+ s = s.to_s
+ __printstr__ s
+ __printstr__ "\n" if (s[-1] != "\n")
+ end
+ i += 1
+ end
+ __printstr__ "\n" if len == 0
+ nil
+ end
+
def printf(*args)
__printstr__(sprintf(*args))
nil