Skip to content

Instantly share code, notes, and snippets.

@ThinaticSystem
Last active August 10, 2025 04:07
Show Gist options
  • Select an option

  • Save ThinaticSystem/662157352efd9e0f2e3c7a96b27d982a to your computer and use it in GitHub Desktop.

Select an option

Save ThinaticSystem/662157352efd9e0f2e3c7a96b27d982a to your computer and use it in GitHub Desktop.
タグ付きテンプレートばかげる
function ばかげる(
normals: Readonly<TemplateStringsArray>,
...embededs: readonly unknown[]
): string {
/*
* NOTE: テンプレートリテラルによる呼び出しと各パラメーターの対応
* - `normals[0]${embededs[0]}normals[1]`
* - `normals[0]` (embededs => [])
* - `${embededs[0]}` (normals[0] => "", normals[1] => "")
*/
const CAPS = "「ばかげている」トランプ大統領が中止を宣言 大統領令に署名へ";
return embededs
.map((embeded, index) =>
normals[index] + embeded)
.concat(normals.at(-1)!) // NOTE: "normals"の要素数は常に"embededs"の要素数+1
.join("")
+ CAPS;
}
@ThinaticSystem
Copy link
Author

ThinaticSystem commented Aug 8, 2025

▶️Run on TS Playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment