LoginSignup
0
0

More than 1 year has passed since last update.

はじめに

移植やってます。

* ** (Python)

class A:
    def init(*args, **kwargs):
        print(args)
        print(kwargs)

a = A
a.init('dog', 'pet', name='poti', age=10, sex='male')

# ('dog', 'pet')
# {'name': 'poti', 'age': 10, 'sex': 'male'}

argsはタプル、* -> ** の順にする。

* ** (Ruby)

class A
  def init(*args, **kwargs)
    p [args, kwargs]
  end
end

a = A.new
a.init('dog', 'pet', name: 'poti', age: 10, sex: 'male')

# [["dog", "pet"], {:name=>"poti", :age=>10, :sex=>"male"}]

Rubyでは、argsはタプルではなく配列になります。

メモ

  • Python の * ** を学習した
  • 道のりは遠そう
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0