Skip to content

Create 2. Add Two Numbers.md#41

Merged
Mike0121 merged 1 commit intomainfrom
2.-Add-Two-Numbers
Nov 1, 2025
Merged

Create 2. Add Two Numbers.md#41
Mike0121 merged 1 commit intomainfrom
2.-Add-Two-Numbers

Conversation

@Mike0121
Copy link
Copy Markdown
Owner

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

私ならvalue1, value2 = get_value(l1), get_value(l2)と一行で書きたくなります

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

私はこの関数名をmoveNodeとしていましたが、moveしない場合があるのでnext_nodeの方が良さそうですね

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dummy が使う値ならば dummy という名称はちょっとずれている気がしますね。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こっちを dummy と呼ぶのは自然でしょう。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほどです。ありがうございます。確かに、1個目はdummyというより、added_headとかが良いですね。意識できていなかったので、覚えておきます。

Comment on lines 116 to 118
Copy link
Copy Markdown

@seal-azarashi seal-azarashi Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

三項演算子にしても良いかなと思いました。Python の記法は独特で、嫌いだと言っている人も見たことがありますが、処理を英語で読み上げているような感じがして私は結構好きです。

Suggested change
if node is None:
return 0
return node.val
return node.val if node else 0

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有難うございます。特に考えずこの書き方していましたが、三項演算子のほうが自分的にも見やすいです。
Python の記法は独特で、嫌いだと言っている人も見たことがあります
存じ上げなかったです。自分も特に違和感ないです。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引数を書き換えているのが気になりました。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。そうですね、特にメリットないので中で別で変数作った方がわかりやすいですね。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Mike0121/LeetCode/pull/41/files#r1695305381
と指摘内容が被りますが
value1,value2への代入をやめると、余計な変数を増やさずに済むのでコードがシンプルになって読みやすくなりそうです。

Copy link
Copy Markdown
Owner Author

@Mike0121 Mike0121 Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有難うございます。確かにこの変数減らせますね。そっちの方が良さそうです。

@rihib rihib mentioned this pull request Aug 6, 2024
@Mike0121 Mike0121 merged commit d5978d3 into main Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants